Skip to content

Instantly share code, notes, and snippets.

@Fcmam5
Created August 13, 2016 11:08
Show Gist options
  • Select an option

  • Save Fcmam5/d3eb594ec7ac41fb962c6c5877b12c7c to your computer and use it in GitHub Desktop.

Select an option

Save Fcmam5/d3eb594ec7ac41fb962c6c5877b12c7c to your computer and use it in GitHub Desktop.
A "" cat file | wc -l "" like program for #learnyounode
var fs = require("fs");
//Readfile
fs.readFile(process.argv[2], (err, content) =>{
if (err) {
throw err;
}
else{
var buffer = content.toString();
var bufferArray = buffer.split('\n');
console.log((bufferArray.length-1));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment