I have a test.js
file with the following content:
let i = ''
process.stdin.on('data', (c) => (i += c))
process.stdin.on('end', () => {
const { EOL } = require('os')
const lines = i.split(EOL)
console.log(lines)
})
I figured out that when I run this line bellow I read from input.txt
and output to output.txt
. Everything works just fine.
node test.js < input.txt > output.txt
However, I cannot find any info in node.js official docs about command line arguments like <
and >
. Am I looking in a wrong place? Is there somewhere a full list of possible arguments of this type and how to use them? Thanks.
<
and >
are not command line arguments to node
. Rather, in most shells, they are part of a feature known as I/O Redirection , which you can use to redirect the input and output of a program. According to the link above:
Redirection simply means capturing output from a file, command, program, script, or even code block within a script and sending it as input to another file, command, program, or script.
If you would like more information about actual command line arguments you can pass to node
, you can run node --help
or visit the official docs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.