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.

1
  • And if you need to do this for an arbitrary number of strings, enclose it in a for loop. For example: for searchString in "string1 string2 stringn"; do grep -H $searchString file1.txt file2.txt; done However, this assumes that searchString is an easy word -- if it has symbols, spaces, you need more escaping. Commented Apr 28, 2011 at 15:13