bash脚本中的EOF错误

时间:2018-04-05 12:50:21

标签: 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"
else
echo "No keyword appeared";
fi
done

1 个答案:

答案 0 :(得分:1)

基于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.