I'd like to make utilities in Node JS which can be used like:
node util.js | node util2.js just as you would using say
cat * | grep str etc.
Use the process.stdin and process.stdout streams.
Here's an example from those docs:
process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { process.stdout.write('data: ' + chunk); }); process.stdin.on('end', function () { process.stdout.write('end'); }); Calling process.stdin.resume() starts the flow of data from standard input and will keep your program running until stdin is paused or ends.