Skip to main content
added 79 characters in body
Source Link
taliezin
  • 9.5k
  • 1
  • 37
  • 39

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html and js files, which after update are excluded with option --exclude for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep --exclude=\*.{js,html} "pattern" 

Where as mentioned in comment also you may use --exclude-from=FILE option.

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html and js files, which after update are excluded with option --exclude for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html and js files, which after update are excluded with option --exclude for example:

find /path/to/dir -type f -print | xargs file | grep text | cut -f1 -d: | xargs grep --exclude=\*.{js,html} "pattern" 

Where as mentioned in comment also you may use --exclude-from=FILE option.

added 62 characters in body
Source Link
taliezin
  • 9.5k
  • 1
  • 37
  • 39

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html and js files, which after update are excluded with option --exclude for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html files for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html and js files, which after update are excluded with option --exclude for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 
added 1 character in body
Source Link
taliezin
  • 9.5k
  • 1
  • 37
  • 39

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html files for example:

find /path/to/dir -type f -print | xargs file | grep --exlude=\*exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html files for example:

find /path/to/dir -type f -print | xargs file | grep --exlude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 

If you want to restrict only by file extension you can use grep --include option:

grep -R --include="*.txt" "pattern" /path/to/dir/ 

Another approach is to eliminate files which are not text but it will include html files for example:

find /path/to/dir -type f -print | xargs file | grep --exclude=\*.{js,html} text | cut -f1 -d: | xargs grep "pattern" 
added 21 characters in body
Source Link
taliezin
  • 9.5k
  • 1
  • 37
  • 39
Loading
Source Link
taliezin
  • 9.5k
  • 1
  • 37
  • 39
Loading