Quantcast
Channel: Why does `watch` make `ls /tmp` list contents of $HOME? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Why does `watch` make `ls /tmp` list contents of $HOME?

0
0

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?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images