Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== grep ====== http://www.gnu.org/software/grep/ ===== Command line usage ===== <code> grep [options] PATTERN [FILE...] grep [options] [-e PATTERN | -f FILE] [FILE...] </code> ===== Examples ===== |printenv <html>|</html> 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 .log<code>grep -R -n -iE 'todo|fixme' . | grep -v -E '\.svn|\.log'</code> * search all files in this directory and lower, finding carriage returns (\r, ^M)<code> grep -U -R -P '\x0d' * or list files only (this example uses octal carriage return) grep -U -R -l -P '\015' * </code> docs/unix/grep.txt Last modified: 2013/05/09 11:46by billh