Grep command
From RZWiki
A command line program available on Linux platforms; used to used to search for regular expressions within files.
Contents |
Usage Syntax
grep [options] string [file/file_pattern...]
Common options include;
- -r or -R - read files recursively
- -A nn - display the specified nn number of lines after each match
- -B nn - display the specified nn number of lines before each match
- -C nn - context: display the specified nn number of lines before and after each match
- -c - count: display a count of lines containing the specified string
- --colour - colour the matching string in any output
- -E - interpret the specified string as an extended regular expression
- -f - obtain search strings from the specified file
- -H - prefix each line of output with the file name the match was found in
- -i - ignore case in both the specified string and file
- -n - prefix each line of output with the line number of the match in the file
Usage Examples
grep -R -C 5 power.png * - search for the string power.png in all files (*) in the present working directory and any subdirectories (-R) and display 5 lines of text before and after each match (-C 5)
Usage Notes
string can include regular expressions
Linux Usage Notes
With most Linux or Unix commands;
- Non root users may need to prefix commands with the sudo command, for example: sudo chmod 644 *
- Brief help can be displayed using the -h or --help parameter, for example: chmod --help
- A full command manual can be displayed using the man command followed by the command name, for example: man chmod
- Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
- Version information can normally be display using the -v, -V or --version parameter, for example: chmod --version. However, this paramater is also frequently used to display verbose output.
noinclude/noinclude
Related Commands
Use the zgrep command to search for regular expressions within files compressed with the compress or gzip commands.
Use the zipgrep command to search for regular expressions within ZIP compressed files.
Command Equivalents
The Cisco command equivalent is the
The Extreme command equivalent is the
The Linux command equivalent is the
The F5 BigIP command equivalent is the
The Blue Coat SGOS command equivalent is the
The XXX platform command equivalent has the same name:
The closest Nokia IPSO command equivalent is the
Related Articles
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Linux commands
Information on F5 BigIP commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands
(replacing the # with an @) |






