2
我想寫一個腳本來跟蹤文件更改的進度。UNIX shell腳本while循環
我有以下至今:
#!/bin/sh
old=‘ls -l /tmp/file‘
new=‘ls -l /tmp/file‘
while [ "$old" = "$new" ]
do
new=‘ls -l /tmp/file‘
done
echo "The file has been changed"
運行時給出了消息的上述程序:
new: command not found
能有人幫。
感謝
你可能想' 「$老」 -eq 「$新的」' –
@Marc,不,在殼'='是字符串比較和'-eq'是數值比較。 –
@Mike,你可能想在你的while循環中拋出一個'sleep 5'。 –