"
grep
is invoked two times, which may be considered suboptimal" – I can see from this answer there is an elegant way with one grep
, still in general there is no guarantee that one grep
performs better than grep | grep
. I can imagine in some cases clever piping may win. You were even willing to accept a different tool. Would you measure its performance and compare to 2xgrep
? Or would you assume one tool is better than a pipe of two? For a small dataset it wouldn't matter anyway. My point is "optimization for optimization's sake" may be wrong.