Skip to content

grep

Look for a string of text within several files in a folder

sh
grep -nr '<string>' <path>

Where:

  • -n: show the line number of the match
  • -r: recurse into sub-directories
  • '<string>' looks for instances of <string> in your files
  • <path>: looks at the files in this directory and all sub-directories

Example:

sh
grep -nr 'foobar' my-project/lib/
my-project/lib/file_one.txt:17:There is a foobar in here
my-project/lib/nested/folder/file_two.txt:42:I found a foober here too

See also

This work is licensed under CC BY-NC-ND 4.0