I'm trying to watch number of files in my /tmp/
directory. For this I thought this command would work:
watch sh -c 'ls /tmp/|wc -l'
But it appears to work as if ls
had no arguments. Namely, I'm in ~
, and I get number of files there instead of /tmp/
. I found a workaround, which seems to work:
watch sh -c 'ls\ /tmp/|wc -l'
But why do I need to escape the space between ls
and /tmp/
? How is the command transformed by watch
so that ls
output is feeded to wc
, but /tmp/
is not passed as argument to ls
?