Let's say there is a file demo.js. If I run it like this:
$ node demo.js | grep keyword then I can get a string which is returned by demo.js and then use grep to handle it.
My question is how to return the string in demo.js?
process.stdout.write I found this is correct.
console.log() wrong ? In fact, console.log() internally uses process.stdout.write but with little bit of formatting. Also, stdout.write will not print a newline automatically, so .. you cant "really" use process.stdout.write to work with grep correctly (unless you add \n yourself, which will be a complete waste)
demo.jsto be served as input to the samedemo.js?console.log("your message")?