1

How to grep a specific line _and_ the first line of a file?

view story
linux-howto

http://unix.stackexchange.com – Assuming a simple grep such as: $ psa aux | grep someApp 1000 11634 51.2 0.1 32824 9112 pts/1 SN+ 13:24 7:49 someApp This provides much information, but as the first line of the ps command is missing there is no context for the info. I would prefer that the first line of ps be shown as well: $ psa aux | someMagic someApp USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 1000 11634 51.2 0.1 32824 9112 pts/1 SN+ 13:24 7:49 someApp Of course, I could add a regex to grep specifically for ps: $ ps aux | grep -E "COMMAND|someApp" However, I w (HowTos)