shell 脚本可以运行,但会出现丢弃错误 "line[8] expected argument ["
shell script works but drop error "line[8] expected argument ["
我有 shell 有效的脚本(做我想做的,查找列出的用户是否在线),但每次都出现错误 "line[8] expected argument ["。我试过使用 == 但同样的事情。这是我的代码:
#!/bin/sh
truth=0;
until [ $truth -eq 1 ]
do
for i; do
isthere=$(who is here | awk '{print }' | grep $i)
if [ $isthere = $i ] #(8 line is here)
then
echo "found user: "$isthere". program now will close.";
exit 0;
fi
done
echo "user not found, retrying after 3sec...";
sleep 3;
done
感谢您的帮助和时间。
看起来 $isthere
或 $i
是空的。你应该引用它们:if [ "$isthere" = "$i" ]
在其他新闻中:大多数分号是无用的;分号它不是语句 terminator,而是语句 separator,以及换行符。
我有 shell 有效的脚本(做我想做的,查找列出的用户是否在线),但每次都出现错误 "line[8] expected argument ["。我试过使用 == 但同样的事情。这是我的代码:
#!/bin/sh
truth=0;
until [ $truth -eq 1 ]
do
for i; do
isthere=$(who is here | awk '{print }' | grep $i)
if [ $isthere = $i ] #(8 line is here)
then
echo "found user: "$isthere". program now will close.";
exit 0;
fi
done
echo "user not found, retrying after 3sec...";
sleep 3;
done
感谢您的帮助和时间。
看起来 $isthere
或 $i
是空的。你应该引用它们:if [ "$isthere" = "$i" ]
在其他新闻中:大多数分号是无用的;分号它不是语句 terminator,而是语句 separator,以及换行符。