Node.js fs read file via command line parameter

Description

Node.js fs read file via command line parameter

var fs = require('fs');
var buf = fs.readFileSync(process.argv[2]);
//console.log(buf);
var str = buf.toString();
//console.log(str);
var n = str.split('\n').length-1;
console.log(n);//  www .  ja  v  a2 s  . co  m



PreviousNext

Related