You are overthinking this and you don't need tee
, head
or tail
.
You can consume the first line using read
and just print it out, then use grep
on the rest:
$ printf "foo\nbar\nquux\n" | { read v; echo "$v"; grep -v bar; }
foo
quux
Or, combining the logic into a single awk
statement and avoiding the problem altogether:
$ printf "foo\nbar\nquux\n" | awk 'NR==1{print;next} !/bar/'
foo
quux