Using the GREP Command

   

Home Up

 

Using GREP

The Search Utility to find data in files.

 

 

grep ...

 

syntax

 

[-A | --after-context= num] [-a | --text]

[-B | --before-context= num] [-b | --byteoffset][--binary-files= type]

[-C | --context= num] [-c | --count] [--color[= when]]

[-D | --devices= action] [-d | --directories= action]

[-E | --extendedregexp][-e | --regexp=pattern] [--exclude=pattern] [--exclude-from= file]

[-f | --file= file] [-F | --fixed-strings]

[-G | --basicregexp]

[-h | --no-filename] [-H | --withfilename]

[-i | --ignore-case] [-I] [--include= pattern] [-l | --files-with-matches]

[-L | --files-without-match] [--label= label][--line-buffered]

[-m | --max-count=num][--mmap]

[-n | --line-number] [-NUM] [-o | --only-matching]

[-P | --perl-regexp]

[-q | --quiet | --silent]

[-R | -r | --recursive]

[-s | --no-messages]

[-U | --binary] [-u | --unixbyte-offsets]

[-v | --invert-match] [-V | --version]

[-w | --word-regexp]

[-x | --lineregexp]

[-Z | --null] [-z | --null-data] pattern files

 

Summary

 

[-A | --after-context= num]: Print num lines of trailing context.

[-a | --text]: Same as specifying ‘binaryfiles=text.’

[-B | --before-context= num]: Print num lines leading context.

[-b | --byte-offset]: Print byte offsets. [--binary-files= type]: Consider binary files to be the type specified. One of ‘text,’ ‘binary’ or

‘without-match.’

[-C | --context= num]: Print num lines of output context.

[-c | --count]: A count of the pattern matches by file.

[--color[= when]]: Uses color when condition matches.

[-D | --devices= action]: How should devices be handled? ‘read’ or ‘skip.’

[-d | --directories= action]: How should directories be handled? ‘read’, ‘recurse’ or ‘skip.’

[-E | --extended-regexp]: The pattern specified is made of up of an extended regular expression.

[-e | --regexp= pattern]: The pattern specified is a regular expression.

[--exclude= pattern]: Matching files will not be searched.

[--exclude-from= file]: Files that match patterns from the specified file will not be searched.

[-f | --file= file]: Get the pattern from the file in this switch.

[-F | --fixed-strings]: The pattern specified is made of up newline separated strings.

[-G | --basic-regexp]: The pattern specified is made of up a basic regular expression.

[-h | --no-filename]: Do not print the filename for a match.

[-H | --with-filename]: For each match, print the filename in which it was found.

[-i | --ignore-case]: Ignore case.

[-I] : Same as specifying ‘binary-files=withoutmatch’

[--include= pattern]: Matching files will be included in the search.

[-l | --files-with-matches]: A list of files that had a match.

[-L | --files-without-match]: A list of files that did not have a match.

[-m | --max-count= num]: Stop searching after the specified number of matches.

[-o | --only-matching]: Output only the portion of the line that matches the search pattern.

[-P | --perl-regexp]: The pattern specified is made of up a Perl regular expression.

[-q | --quiet | --silent]: Suppress output.

[-R | -r | --recursive]: Same as ‘--directories=recurse.’

[-s | --no-messages]: Do not display error messages.

[-U | --binary] [-u | --unix-byte-offsets]: Does not strip carriage return character.

[-v | --invert-match]: Select lines that do not match the pattern.

[-V | --version]: Get program version information.

[-w | --word-regexp]: Match whole words only.

[-x | --line-regexp]: Match whole lines only.

[-z | --null-data]: The data line does not end with newline but with 0 bytes instead.

 

pattern: The pattern to match.

files: The search file or location.

 

 

Order a book or two today - you can download an eBook today for only $1.99!

            

Just click on a book to learn more!