これは基本ですが、グーグルできません。grepの呼び出しに使用できますか
grep expr1 | grep expr2
expr1とexpr2の両方を含む行を出力するように?
Try this:
grep 'expr1.*expr2\|expr2.*expr1'
That's a little more complicated than it needs to be if you know that "expr2" will always come after "expr1". In that case, you could simplify it to:
grep 'expr1.*expr2'
What you have should work.
The following is an alternative way to achieve the same effect:
grep -E 'expr1.*expr2|expr2.*expr1'
Actually your own suggestion is nearly correct if you want to get the lines that contain both expressions. Use:
grep expr1 somefile | grep expr2