fgrep
Search files for fixed string patterns
TLDR
View documentation for the original command
SYNOPSIS
fgrep [options] PATTERN [FILE…]
PARAMETERS
-i, --ignore-case
Ignore case distinctions in patterns and data
-v, --invert-match
Select non-matching lines
-n, --line-number
Prefix each line with its line number
-l, --files-with-matches
Output only names of files containing matches
-c, --count
Suppress normal output; show count of matching lines per file
-w, --word-regexp
Match only whole words (selects lines with exact word matches)
-x, --line-regexp
Select only matches that exactly match entire lines
-f FILE, --file=FILE
Read patterns from FILE (one per line)
-h, --no-filename
Suppress filename prefix on output
-q, --quiet, --silent
Suppress all output; exit status indicates match
DESCRIPTION
fgrep, short for "fixed grep", is a utility for searching files for literal strings rather than regular expressions. Unlike grep (which interprets patterns as basic regex) or egrep (extended regex), fgrep treats all patterns as fixed strings, enabling faster searches on large files or datasets without regex parsing overhead.
It reads patterns from the command line or a file and scans input files (or stdin) line-by-line, printing matching lines by default. Ideal for searching configuration files, logs, or code for exact terms like error messages, keywords, or identifiers.
Key advantages include speed on non-regex patterns and simplicity for literal matches. Output includes the filename (unless suppressed) and line content. Common in scripts for batch processing. On modern GNU systems, fgrep is typically a symlink to grep with the -F flag implied, ensuring POSIX compatibility while leveraging grep's enhancements.
CAVEATS
Deprecated on some systems; use grep -F for portability. Does not support regex metacharacters as literals unless escaped. Multiple patterns separated by newlines or pipes treated as alternatives.
EXIT STATUS
0: Matches found
1: No matches
2: Error
EXAMPLES
fgrep 'error' *.log
fgrep -i -l 'TODO' src/*.c
fgrep -f patterns.txt largefile
HISTORY
Introduced in early Unix Version 7 (1979) alongside grep and egrep for optimized literal searches. Maintained in POSIX standards for compatibility. In GNU coreutils since 1987, fgrep links to grep with fixed-string mode.


