====== grep ====== http://www.gnu.org/software/grep/ ===== Command line usage ===== grep [options] PATTERN [FILE...] grep [options] [-e PATTERN | -f FILE] [FILE...] ===== Examples ===== |printenv | grep lib|print 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...)| ===== Complex Examples ===== * find all todo's and fixme's, ignoring case, from this directory and deeper, ignoring any results with .svn or .loggrep -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' *