how to print ps header when using pipe in linuxthis normal ps output$ ps -efUID         PID   PPID  C STIME TTY          TIME CMDroot          1      0  0 17:00 ?        00:00:02 /usr/lib/systemd/systemdbut below ps command output without header$ ps -ef | grep systemdroot          1      0  0 17:00 ?        00:00:02 /usr/lib/systemd/systemdhow do i print ps header for second command?thx
how to print ps header when using pipe in linux
ps
My first instinct is to do ps -ef | grep UID && ps -ef | grep systemd, but that will also print the grep commands like so$ ps -ef | grep UID && ps -ef | grep systemdUID         PID   PPID  C STIME TTY          TIME CMDroot          1      0  0 17:00 ?        00:00:02 /usr/lib/systemd/systemduser          PID PPID  C 23:30 ?        00:00:00 grep systemduser          PID PPID  C 23:30 ?        00:00:00 grep UIDI don't see how you can print only the header, because any time you execute this, the regex will match the grep itself. 