Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 9
    grep foo | grep bar is a more general way to do AND. Commented Jan 5, 2015 at 15:43
  • 4
    +1 for clearly explaining that there isn't a real "AND" operator, and that the best we can do is simulate a hack using an OR structure. This will of course get unwieldy with more than 3 terms, but for two terms it works well. Commented Apr 20, 2017 at 15:57
  • grep -c -e MATCH1 -e MATCH2 is great when you are interested in filename counts. Commented Jul 10, 2019 at 11:26