Search file(s) for lines that match a fixed string

      fgrep options ...

fgrep is the same as 'grep -F'

all other options are the same as grep 

It's a popular fallacy that fgrep stands for fast-grep, in fact fgrep means fixed-string grep.

fgrep implements the Aho–Corasick string matching algorithm which is very fast at matching multiple strings in the input stream/file. So if fgrep is used like this:

fgrep -f patternlist.txt largetextfile.txt

it is much faster than the grep equivalent:

grep -f patternlist.txt largetextfile.txt

Matching a single pattern with fgrep is not significantly faster than grep.

"The knowledge imposes a pattern, and falsifies, For the pattern is new in every moment..." ~ T. S. Eliot

Related linux commands

egrep - Search file(s) for lines that match an extended expression.
gawk - Find and Replace text within file(s).
grep - Search file(s) for lines that match a given pattern.
Equivalent Windows command: FINDSTR - Search for strings in files.

Copyright © 1999-2024 SS64.com
Some rights reserved