我在文件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如果有任何愚蠢的錯誤,請原諒我。
+ 1你們真的很快!!! – Kent
因爲有一次我打你:-) –
我剛剛發現OP的ID很快! :D – Kent