Using watch command with "echo -e"
The output is static because $()
is resolved by your shell before watch
starts.
Quoting with ''
should help. Single quotes prevent expansion, this way $()
will be passed literally to watch
, then parsed every time:
watch -n .1 'echo -e "$(cat test-status | wc -l)/$(cat iplist_test | wc -l)"'
Also you misuse cat
. This should work without any unnecessary cat
processes:
watch -n .1 'echo -e "$(<test-status wc -l)/$(<iplist_test wc -l)"'
If there are single-quotes already in the command you want to watch then see this: How can I single-quote or escape the whole command line in Bash conveniently?