docs:unix:grep

grep

grep [options] PATTERN [FILE...]
grep [options] [-e PATTERN | -f FILE] [FILE...]
printenv <html></html> grep libprint a list of environment variables that contain “lib”
grep -e foo -R -n . search from current directory and below, inside of files for “foo”, and print a list of file paths, line numbers, and lines that match
grep -e foo -R -l . search from current directory and below, inside of files for “foo”, and only print a list of files that match
grep -i foo -R -l . same as previous, but case insensitive “foo” (foo, Foo, FOO, etc…)
  • find all todo's and fixme's, ignoring case, from this directory and deeper, ignoring any results with .svn or .log
    grep -R -n -iE 'todo|fixme' . | grep -v -E '\.svn|\.log'
  • search all files in this directory and lower, finding carriage returns (\r, ^M)
    grep -U -R -P '\x0d' *
    or list files only (this example uses octal carriage return)
    grep -U -R -l -P '\015' *
  • docs/unix/grep.txt
  • Last modified: 2013/05/09 11:46
  • by billh