ファイルtest.shの./test.sh:行13:[:missing ']' 大括弧や-aなどのその他のオプションを使用して試してみましたファイルp1のサイズですが、エラーは常に存在し、else文は指定された入力に関係なく常に実行されます。 13行目にあるが、それは役に立たなかった。Bashスクリプトがありません ']'
test.sh
#!/bin/bash
echo "Enter app name"
read y
$y &
top -b -n 1 > topLog.log
#-w checks for the whole word not and sub string from that word
grep -w "$y" topLog.log > p1
#-s option checks if the file p1 is present or not
if [ -s "p1"]; #line 13
then
echo "Successful "
else
echo "Unsuccessful"
fi
rm p1
私は私をお許しください任意の愚かな間違いがある場合scripting.Soをbashに新しいです。
+ 1あなたは本当に素早いです! – Kent
一度私はあなたを打つ:-) –
私はちょうどOPのIDが迅速であることがわかった! : – Kent