Sometimes we need to find all files containing a specific text withing the files, not in the file name. We can achieve this with grep and a few parameters:
1
grep -irnwl /path -e 'pattern'
- -i ignore case
- -r recursive
- -n line number
- -w match the whole word (Do not use if not necessary)
- -l give the file name
- -e searched pattern
If we want to find several words we can do it using several -e options and arguments:
1
grep -irnwl /path -e 'pattern1' -e 'pattern2'
Or using the -E (extended regular expression) option and separating the words with the vertical bar:
1
grep -irnwE 'pattern1|pattern2' /path
Enjoy! ;)