我似乎在执行此脚本时遇到了一些问题?不确定是什么导致了这个问题?
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
答案 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.