Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:grep_recursively_through_single_file_extension [2011/03/22 20:51]
Joel Dare
linux:grep_recursively_through_single_file_extension [2020/06/01 22:53] (current)
Line 1: Line 1:
 +====== Grep Recursively Through Single File Extension ======
  
 +You can use the following //grep// command to search through a directory, recursively,​ but only looking at a specific file pattern.
 +
 +  grep -r --include=<​pattern>​ <​string>​ <​directory>​
 +
 +Here is an example that searches recursively starting at /home/joel/ and including only php files.
 +
 +  grep -r --include="​*.php"​ "​public auction"​ ./
 +
 +Other options you might want to add to the command:
 +
 +| -i | Case insensitive match. |
 +| -c | Count of matches; suppressing normal output. ​ One line per file match. |
 +| -o | Show only the part of a matching line that matches. |
 +
 +Here's another example with the -r, -i and -o options all added.
 +
 +  grep -rio --include="​*.php"​ "​public auction"​ ./
comments powered by Disqus
linux/grep_recursively_through_single_file_extension.txt · Last modified: 2020/06/01 22:53 (external edit)