This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:grep_with_and [2012/12/12 20:51]
Joel Dare created
linux:grep_with_and [2020/06/01 22:53] (current)
Line 1: Line 1:
 +====== Grep with AND ======
 +You can use grep to search for any line from any file in the current path that contains one word and another word.  Here's how.
 +  grep -Ers '​cpage.*gallery'​ ./
 +  ​
 +This uses the //-E// command line argument to indicate that our search string is a regular expression. ​ Then, we can use "​.*"​ to indicate look for everything. ​ As a result, the above example will look for any line that includes the string '​cpage'​ followed by anything and then followed by '​gallery'​. ​ The -r switch makes it recursive and the -s switch makes it suppress errors such as 'No file or directory.'​
comments powered by Disqus
linux/grep_with_and.txt · Last modified: 2020/06/01 22:53 (external edit)