Grep command

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

The grep command searches the given input files for lines containing a match to the given PATTERN. By default, grep prints the matching lines. It has no limits on input line length other than available memory, and it can match arbitrary characters within a line.

grep Syntax

The general syntax is as follows:

grep Options Search-Pattern InputFileNames


In this example, you are printing the version number of grep command:

grep -V


grep --version

Sample outputs:

GNU grep 2.5.4

Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

See also