Can I reload variable in a watch command?

Contrast:

$ watch -n 1 "echo $(date)"
Every 1.0s: echo Sat Apr 27 03:10:50 CEST 2013

$ watch -n 1 'echo $(date)'
Every 1.0s: echo $(date)

What you've done is to run echo "($ls DirFlat |wc -l)*100/$FileNum"|bc and date, substitute the output of each command into the shell command watch -n 100 "echo $(…) % $(…)", and run that. You need to prevent the expansion of the command in the parent shell, and instead pass it as a string to watch for it to run. This is a simple matter of using single quotes around the command instead of double quotes.


Alternatively you can wrap it into a shell loop:

while sleep 100; do
    (... your stuff ...)
    if [ (... process has finished ...) ]; then
        (... beep or get operator's attention otherwise ...)
        break
    fi
done