Name
fgrep [options
] [fixed_strings
] [files
] — grep
Synopsis
/bin
stdin stdout - file -- opt --help --version
The fgrep
command is just like grep
, but instead of accepting a regular expression, it accepts a list of fixed strings, separated by newlines. It’s the same as grep -F
. For example, to search for the strings one, two, and three in a file:
$ fgrep 'one Note we are typing newline characters
two
three' myfile
fgrep
is commonly used with the lowercase -f
option, which reads patterns from a file. For example, if you have a dictionary file full of strings, one per line:
$ cat my_dictionary_file aardvark aback abandon ...
you can conveniently search for those strings in a set of input files:
$ fgrep -f my_dictionary_file *
fgrep
also is good for searching for nonalphanumeric characters like * and { because they are taken literally, not as metacharacters in regular expressions.
Get Linux Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.