GREP(1) General Commands Manual GREP(1) NAME grep, egrep, fgrep - SYNOPSIS grep [options] PATTERN [FILE...] grep [options] [-e PATTERN | -f FILE] [FILE...] DESCRIPTION Grep FILE ( - ) PATTERN grep egrep fgrep Egrep grep -E Fgrep grep -F OPTIONS -A NUM, --after-context=NUM NUM -- -a, --text --binary-files=text -B NUM, --before-context=NUM NUM -- -C NUM, --context=NUM NUM -- -b, --byte-offset --binary-files=TYPE TYPE TYPE binary grep TYPE without-match grep -I TYPE text grep -a grep --binary-files=text --colour[=WHEN], --color[=WHEN] GREP_COLOR WHEN `never', `always', `auto' -c, --count -v, --invert-match () -D ACTION, --devices=ACTION FIFO (socket) ACTION ACTION read ACTION skip -d ACTION, --directories=ACTION ACTION ACTION read ACTION skip ACTION recurse grep -r -E, --extended-regexp PATTERN () -e PATTERN, --regexp=PATTERN PATTERN - -F, --fixed-strings PATTERN (newlines) -P, --perl-regexp PATTERN Perl -f FILE, --file=FILE FILE 0 -G, --basic-regexp PATTERN () -H, --with-filename -h, --no-filename --help -I --binary-files=without-match -i, --ignore-case PATTERN -L, --files-without-match -l, --files-with-matches -m NUM, --max-count=NUM NUM NUM grep grep NUM -c --count grep NUM -v --invert-match grep NUM --mmap mmap(2) read(2) --mmap grep I/O --mmap (core dumps) -n, --line-number -o, --only-matching PATTERN --label=LABEL LABEL zgrep gzip -cd foo.gz |grep --label=foo something --line-buffering it can be a performance penality. -q, --quiet, --silent 0 -s --no-messages -R, -r, --recursive -d recurse --include=PATTERN PATTERN --exclude=PATTERN PATTERN -s, --no-messages GNU grep grep POSIX.2 grep -q -s GNU grep -q grep shell -q -s /dev/null -U, --binary MS-DOS MS- Windows grep 32kB grep CR ( ^ $ ) -U CR/LF MS-DOS MS-Windows -u, --unix-byte-offsets Unix grep Unix CR Unix grep -b MS-DOS MS-Windows -V, --version grep bug () -v, --invert-match -w, --word-regexp -x, --line-regexp -y -i -Z, --null (ASCII NUL ) grep -lZ find -print0, perl -0, sort -z, xargs -0 REGULAR EXPRESSIONS Grep "basic" "extended" GNU grep (basic) (extended) (may be quoted by preceding it with a backslash.) (bracket) [ ] (caret) ^ [0123456789] (range) (hyphen) (that sorts between the two characters,inclusive, using the locale's collating sequence and character set.) C locale [a-d] [abcd] locale locale [a-d] [abcd] [aBbCcDd] LC_ALL C locale C [:alnum:](), [:alpha:](), [:cntrl:](), [:digit:](), [:graph:](), [:lower:](), [:print:](), [:punct:](), [:space:](), [:upper:](), [:xdigit:] [[:alnum:]] [0-9A-Za-z] locale C ASCII locale () (literal) ] (literal) ^ (literal) - (period) . \w [[:alnum:]] \W [^[:alnum]] (caret) ^ (dollar) $ \< \> \b (edge) \B ? * + {n} n {n,} n {n,m} n m | (parentheses) (to override these precedence rules.) \n n n ?, +, {, |, (, ) (backslash) \?, \+, \{, \|, \(, \) egrep { egrep \{ egrep { [{] (literal) { GNU egrep { an invalid interval specification shell egrep '{1' {1 POSIX.2 ENVIRONMENT VARIABLES Grep locale LC_foo LC_ALL, LC_foo, LANG, locale LC_ALL LC_MESSAGES pt_BR (Brazilian Portuguese) LC_MESSAGES locale locale grep (national language support (NLS)) locale C GREP_OPTIONS GREP_OPTIONS '--binary-files=without-match --directories=skip' grep --binary-files=without-match --directories=skip (whitespace) (backslash) (escape) GREP_COLOR LC_ALL, LC_COLLATE, LANG locale LC_COLLATE [a-z] (collating sequence) LC_ALL, LC_CTYPE, LANG locale LC_CTYPE (whitespace) LC_ALL, LC_MESSAGES, LANG locale LC_MESSAGES grep locale C POSIXLY_CORRECT grep POSIX.2 grep GNU POSIX.2 POSIX.2 "illegal" (diagnose) "invalid" POSIXLY_CORRECT _N_GNU_nonoption_argv_flags_ _N_GNU_nonoption_argv_flags_ ( N grep's ID) i 1 grep i shell GNU C POSIXLY_CORRECT DIAGNOSTICS 012 -q --quiet --silent BUGS bug bug-gnu-utils@gnu.org "Subject:" "grep" {n,m} grep grep (backreferences) [] [] 2003.11.03 linuxman: http://cmpp.linuxforum.net man man https://github.com/man-pages-zh/manpages- zh GNU Project GREP(1)