Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bash脚本中的EOF错误_Bash - Fatal编程技术网

bash脚本中的EOF错误

bash脚本中的EOF错误,bash,Bash,我似乎在执行这个脚本时遇到了一些问题?不确定是什么导致了问题 touch file cat file | while read line; do output=$(awk '/path/ {print NR, $0}' "$line"); if [$(#output) -ne 0]; then echo "File: " "$line"; echo "----------------------------------------------------"; echo "$output" el

我似乎在执行这个脚本时遇到了一些问题?不确定是什么导致了问题

touch file
cat file | while read line; 
do
output=$(awk '/path/ {print NR, $0}' "$line");
if [$(#output) -ne 0];
then
echo "File: " "$line";
echo "----------------------------------------------------";
echo "$output"
else
echo "No keyword appeared";
fi
done

基于shellcheck.net

第5行:

if [$(#output) -ne 0];
   ^-- SC1035: You need a space after the [ and before the ].
   ^-- SC1009: The mentioned syntax error was in this test expression.
    ^-- SC1073: Couldn't parse this command expansion. Fix to allow more checks.
第6行:

then
    ^-- SC1072: Unexpected keyword/token. Fix any mentioned problems and try again.

如果[condition](
[
]
需要作为单独的标记进行解析,如果它们与其他字符相邻,则不会发生这种情况),请检查
中括号周围是否需要空格