Last Updated: February 25, 2016
·
209
· tkloong

Search a string inside files

Command

grep -ir "string_pattern" 'directories'

Common used parameters

  • -i, --ignore-case ignore case distinctions
  • -R, -r, --recursive equivalent to --directories=recurse
  • -n, --line-number print line number with output lines
  • -E, --extended-regexp PATTERN is an extended regular expression (ERE)
  • -L, --files-without-match print only names of FILEs containing no match
  • -l, --files-with-matches print only names of FILEs containing matches

  • --include=FILEPATTERN search only files that match FILEPATTERN

  • --exclude=FILEPATTERN skip files and directories matching FILEPATTERN

Type "grep --help" for more information!