【发布时间】:2011-09-23 20:36:29
【问题描述】:
我正在尝试编写一个脚本来跟踪文件更改的进度。
到目前为止,我有以下内容:
#!/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
有人可以帮忙吗。
谢谢
【问题讨论】:
-
你可能想要
"$old" -eq "$new" -
@Marc,不,在shell中
=是字符串比较,-eq是数字比较。 -
@Mike,您可能想在您的 while 循环中添加一个
sleep 5。