I'm in a Ubuntu 18.04 environment, and I'm trying to grep the output of lsof to get some detailed info about files being locked on my system.
My command is simple, and goes like so:
sudo lsof | grep 'query'
. This however, always contains the same output, and the output includes many lines which do not match the grep query.
Specifically, I'm getting lines similar to lsof: no pwd entry for UID 496
, and lsof: WARNING: can't stat() overlay file system
.
I suspect this may be because the pipe operator |
only pipes STDOUT, and not STDERR. If this is the case, how do I pipe STDERR and STDOUT to a single command? If this is not the case, why is my grep command printing out things that don't match the query?