I am trying to write a script to track the progress of file change.
I have the following till now:
#!/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"
The above program when run gives the message:
new: comma开发者_如何学Pythonnd not found
Can someone please help.
Thanks
You probably have space around =
.
In shell, when you assign the values you cannot put space around =
:
MY_VAR = "my value" # this is wrong!
Shell will think: "call MY_VAR with arguments: ('=', 'my value') ", but wait! I don't know the command "MY_VAR"!
You need to do it this way:
MY_VAR="my value" # this is OK!
BTW, consider using inotifywatch
command. Here's example:
inotifywatch -v -e access -e modify -t 60 -r /file/to/watch
精彩评论