发现这个功能非常有用,必须收藏起来。

grep -rnw ‘/path/to/somewhere/’ -e ‘pattern’

  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.
  • -e is the pattern used during the search

或者

grep -Ril “text-to-find-here” /

  • i stands for ignore case (optional in your case).
  • R stands for recursive.
  • l stands for “show the file name, not the result itself”.
  • / stands for starting at the root of your machine.