如何将node.js(或类似)程序的输出用作unix命令行输入?

如何将node.js(或类似)程序的输出用作unix命令行输入?,unix,command-line,Unix,Command Line,我有一个简单的节点js程序,名为test\u cmd.js。我想通过unix shell运行这个程序,并使用程序的输出执行unix命令 test_cmd.js可以是: console.log('echo "hello, world!"'); 输出: >> pi@raspberrypi ~/ $ node test_cmd.js >> echo "hello, world!" # I want the unix shell I ju

我有一个简单的节点js程序,名为
test\u cmd.js
。我想通过unix shell运行这个程序,并使用程序的输出执行unix命令

test_cmd.js
可以是:

console.log('echo "hello, world!"');
输出:

>> pi@raspberrypi ~/ $ node test_cmd.js
>> echo "hello, world!" # I want the unix shell I just ran this program in to run this output as a command, but how?

将其作为标准DIN管道传输到外壳:

$ node test_cmd.js | bash
hello, world!