When I pipe to grep after a ps aux command it isn't showing the categories at the top of the list (USER, PID, %CPU, %MEM, etc) Is there something I can do about this?
ps aux --sort -rss | grep $USER | head -n 4
user01 1610 0.0 0.3 17968 10156 ? Ss Jan19 0:01 /lib/systemd/systemd --user
user01 1611 0.0 0.0 104400 2108 ? S Jan19 0:00 (sd-pam)
user01 1617 0.0 0.1 48216 4812 ? S<sl Jan19 0:00 /usr/bin/pipewire
user01 1618 0.0 0.1 32108 4256 ? Ssl Jan19 0:00 /usr/bin/pipewire-media-session
I am expecting to see the following at the very top:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
The example they gave:
ps aux --sort -rss | grep -i 'whoami' | head -n 4
but the output only ever shows one line no matter what number is specified in the head command.I'm supposed to figure out a different way to write it, but am wondering if the
– Onizuka Jan 25 '23 at 18:27'whoami'
could actually be made to work.$(whoami)
not single quotes, to executewhomai
as a command substitution rather than a string literal. See Differences between doublequotes " ", singlequotes ' ' and backtickson commandline? – steeldriver Jan 25 '23 at 18:40