我有一个文本文件,其中每一行都是我想传递给nodejs脚本的参数列表.这是一个示例文件file.txt:
"This is the first argument" "This is the second argument"
Run Code Online (Sandbox Code Playgroud)
为了演示,节点脚本很简单:
console.log(process.argv.slice(2));
Run Code Online (Sandbox Code Playgroud)
我想为文本文件中的每一行运行此节点脚本,所以我创建了这个bash脚本run.sh:
while read line; do
node script.js $line
done < file.txt
Run Code Online (Sandbox Code Playgroud)
当我运行这个bash脚本时,这就是我得到的:
$ ./run.sh
[ '"This',
'is',
'the',
'first',
'argument"',
'"This',
'is',
'the',
'second',
'argument"' ]
Run Code Online (Sandbox Code Playgroud)
但是,当我直接运行节点脚本时,我得到了预期的输出:
$ node script.js "This is the first argument" "This is the second argument"
[ 'This is the first argument',
'This is the second argument' ]
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?是否有更多节点方法可以做到这一点?
我想检测用户是否意外上传了标记为.csv的Excel文件.xls文件是否有标准的二进制占用空间可以实现这一目标?