Useful Linux Commands

Find File Contents
grep --exclude=... --include=... --exclude-dir=... -rnw '/path/' -e 'pattern'


  • r: Search subfolders recursively
  • n: Show line numbers
  • w: Match the whole word


Find files containing "some text" in the current folder, recursively:

grep -rnw './' -e 'some text'

Exclude files with .txt extension:

grep --exclude=*.txt -rnw './' -e 'some text'

Include files with .xml and .json extension:

grep --include=\*.{xml,json} -rnw './' -e 'some text'

And exclude the bin folder:

grep --include=\*.{xml,json} --exclude-dir={bin} -rnw './' -e 'some text'