grep_2 - [ < ] [ > ] [...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [ < ] [ > ] [ << ] [ Up ] [ >> ] [ Top ] [ Contents ] [ Index ] [ ? ] 2. Invoking grep grep comes with a rich set of options from POSIX.2 and GNU extensions. `-c ' `--count ' Suppress normal output; instead print a count of matching lines for each input file. With the `-v ', `--invert-match ' option, count non-matching lines. `-e pattern ' `--regexp= pattern ' Use pattern as the pattern; useful to protect patterns beginning with a `- '. `-f file ' `--file= file ' Obtain patterns from file , one per line. The empty file contains zero patterns, and therefore matches nothing. `-i ' `--ignore-case ' Ignore case distinctions in both the pattern and the input files. `-l ' `--files-with-matches ' Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning of every file will stop on the first match. `-n ' `--line-number ' Prefix each line of output with the line number within its input file. `-o ' `--only-matching ' Print only the part of matching lines that actually matches pattern . `-q ' `--quiet ' `--silent ' Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the `-s ' or `--no-messages ' option. `-s ' `--no-messages ' Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep , traditional grep did not conform to POSIX.2, because traditional grep lacked a `-q ' option and its `-s ' option behaved like GNU grep 's `-q ' option. Shell scripts intended to be portable to traditional grep should avoid both `-q ' and `-s ' and should redirect output to ` /dev/null ' instead. `-v ' `--invert-match ' Invert the sense of matching, to select non-matching lines. `-x ' `--line-regexp ' Select only those matches that exactly match the whole line. [ < ] [ > ] [ << ] [ Up ] [ >> ] [ Top ] [ Contents ] [ Index ] [ ? ] 2.1 GNU Extensions `-A num ' `--after-context= num ' Print num lines of trailing context after matching lines. `-B num ' `--before-context= num ' Print num lines of leading context before matching lines. `-C num ' `--context= num ' Print num lines of output context. `--colour[= WHEN ] ' `--color[= WHEN ] ' The matching string is surrounded by the marker specify in GREP_COLOR . WHEN may be `never', `always', or `auto'. `- num ' Same as `--context= num ' lines of leading and trailing context. However, grep will never print any given line more than once. `-V ' `--version ' Print the version number of grep to the standard output stream. This version number should be included in all bug reports. `--help ' Print a usage message briefly summarizing these command-line options and the bug-reporting address, then exit....
View Full Document

This note was uploaded on 03/07/2012 for the course ACC 231 taught by Professor Richester during the Spring '12 term at Northampton Community College.

Page1 / 7

grep_2 - [ < ] [ > ] [...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online