StudentAnwser=()
inputScriptFile=001.sh
while IFS= read -r line;
do
StudentAnwser+=( "$line" )
done < <( sh $inputScriptFile test.txt )
它返回一个错误
foo.sh: line 22: syntax error near unexpected token `<'
foo.sh: line 22: ` done < <( sh $inputScriptFile test.txt )'
那有什么问题呢?我是按照其他问题的解决方案来读取结果行的。
#!/bin/bash
?如果没有,请编辑你的问题并包含第一行内容。祝好运。 - shellterbash
的有效语法(但如@shellter所说,对于sh
无效)。< <( ... )
与<<( ... )
不同(事实上,后者是错误的)。 - Amadansh
”与你程序的第一行是“不适用于#!/bin/bash
”是不同的。如果在脚本中涉及Windows,则使用dos2unix myScript
。还有,你是否使用了chmod 755 myScript
?(我已经没有更多想法了)。祝你好运。 - shellter