terminal - How to keep column headers when using grep? -
Output of some programs starts with the names of columns (e.g., Now assume that I have frequencies of agetty Want to find: I have seen the beginning of I can print the first line after the matching lines: However, This does not solve my problem when I do not know how many header lines are there lines to get a header there and the method did not match the lines, or some less workaround is to achieve this goal? will this help? Fill in the You can also ps a ): < / P>
$ ps a PID TTY STAT time COMMAND 1306 TTY1 SS + 0:00 / sbin / mingetty / dev / TTY1 1318 hvc0 ss + 0:00 / sbin / agetty hvc0 38400 vt100 -Nav 14,696 points / ss0: 00 -bash 15283 points / r + 00:00 ps a
$ ps a | | Grep agetty 1318 hvc0 ss + 0:00 / sbin / agetty hvc0 38400 vt100- nav 15,339 points / s + 00:00 grapes agetty
ps? Grep agetty means .
$ ps a | Head-N1; Ps a | Grep agetty pid TTY STAT time COMMAND 1318 hvc0 ss + 0:00 / sbin / agetty hvc0 38400 vt100- nav 15542 points / 0s + 00:00 grep agetty
ps .. | Awk '/ yourpattern / ||! ^ * S * [0-9] / '
yourpattern in place.
ps ... | Awk '/ agett [y] / || ... instead of
/ agetty / to filter out the
awk process itself.
Comments
Post a Comment