Sample Header Ad - 728x90

How to pipe grep and keep headers?

0 votes
3 answers
4081 views
In the example below, I have the right selection, but not the headers, and conversely. How can I have both? $ ps aux | grep 'gpart' erwann 200603 0.0 0.0 2608 72 pts/3 S 12:57 0:00 /bin/sh /usr/sbin/gparted root 200608 0.0 0.0 2608 1056 pts/3 S 12:57 0:00 /bin/sh /usr/sbin/gparted root 200693 0.0 0.0 2608 68 pts/3 S 12:57 0:00 /bin/sh /usr/lib/udisks2/udisks2-inhibit /usr/sbin/gpartedbin root 200700 1.9 0.2 264960 18620 pts/3 SLl 12:57 8:31 /usr/sbin/gpartedbin root 202327 99.8 0.0 2520 64 pts/3 R 13:36 400:07 gpart -s 512 /dev/sdc erwann 214723 0.0 0.0 9032 716 pts/4 S+ 20:17 0:00 grep --color=auto gpart $ ps aux | tee >(head -n1) >(grep 'gpart') > /dev/null USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
Asked by Erwann (729 rep)
Jun 19, 2022, 12:20 AM
Last activity: Jun 19, 2022, 05:34 AM