grepwatchlsof

Use of watch and lsof + grep together


When i use

lsof -p 3536693 | grep snapshot

I get an output

but if i try to

watch lsof -p 3536693 | grep snapshot

I get nothing. Aren't they compatible?

It works if I ommit grep, like

watch lsof -p 3536693

Solution

  • It works when the "watched" command is quoted, so:

    watch "lsof -p 3536693 | grep snapshot"