I’m currently using Node.js and am wondering how one would read a range of lines from a large text file. An obvious solution would be like so:
var fs = require('fs');
fs.readFile(file, function(err, data) {
var lines = data.split('\n');
});
However, that would involve loading the entire file into memory, which would be impractical for large text files, such as ones 100MB+.
In Bash, I would normally use sed for this case.
With lazy: