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