sed and awk can also to this (1st line plus any matching lines)
Following transcript from zsh session on my fast Ryzen: $ <<-'@@' time sh -c "grep -m1 USER && grep carenas" USER,TIP john,0 jane,10 carenas,100 @@ USER,TIP carenas,100 sh -c "grep -m1 USER && grep carenas" 0.00s user 0.00s system 93% cpu 0.003 total $ <<-'@@' time sed -n -e 1p -e /carenas/p USER,TIP john,0 jane,10 carenas,100 @@ USER,TIP carenas,100 sed -n -e 1p -e /carenas/p 0.00s user 0.00s system 80% cpu 0.001 total $ <<-'@@' time awk 'NR == 1 || /carenas/' USER,TIP john,0 jane,10 carenas,100 @@ USER,TIP carenas,100 awk 'NR == 1 || /carenas/' 0.00s user 0.00s system 88% cpu 0.002 total As I expected, sed is fastest, grep next, and awk slowest of the three, but the 1, 2, and 3 millisecond totals are within the margin of test error. -- Paul Jackson p...@usa.net