Name
fgrep — stdin stdout - file -- opt --help --version
Synopsis
fgrep [options] [fixed_strings] [files]
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, 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 inputfile1 inputfile2Normally, you’ll use the lowercase -f option to make fgrep read the fixed strings from a file.
You can also read the fixed strings on the command line using quoting,
but it’s a bit trickier. To search for the strings one, two, and three
in a file, you’d type:
➜fgrep 'oneNote we are typing newline characterstwo three' myfile
fgrep is convenient when
searching for non-alphanumeric characters like * and { because they are
taken literally, not as regular expression characters.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access