Follow-up Comment #3, bug #19337 (project grep):
I've often wanted this functionality and would welcome a 'head' option to
grep. I feel it is similar to the A and B options in that it provides
additional context. '--head=2' would include the first two lines of STDIN.
'--head' would assume a default of 1 line.
In SQL, if I do:
SELECT * from EMP;
I get column headers followed by the data. If I filter the rows by adding a
WHERE clause, I still get the column headers. Likewise, if I filter the output
of 'ps aux', I still want the column headers.
I did come up with a workaround:
$ ps aux | (read line; echo "$line"; grep foo)
On some systems, this can be shortened to:
$ ps aux | (head -1; grep foo)
but that didn't work consistently for me across all systems I work on. I
suspect it only works with the most recent versions of coreutils. (If someone
knows why, please add to the discussion.)
Allen Halsey
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?19337>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/