fgrep
text processingLinux/Unix
The fgrep command is one of the most frequently used commands in Linux/Unix-like operating systems. fgrep Search for fixed strings in files
Quick Reference
Command Name:
fgrep
Category:
text processing
Platform:
Linux/Unix
Basic Usage:
fgrep [options] [arguments]
Common Use Cases
Syntax
fgrep [options] pattern [file...]
Options
Option | Description |
---|---|
-i, --ignore-case |
Ignore case distinctions in patterns and data |
-v, --invert-match |
Select non-matching lines |
-n, --line-number |
Display line number with output lines |
-c, --count |
Print only a count of matching lines per file |
-l, --files-with-matches |
Print only names of files containing matches |
-L, --files-without-match |
Print only names of files containing no match |
-f, --file=FILE |
Obtain patterns from FILE, one per line |
-r, --recursive |
Recursively search subdirectories |
-h, --no-filename |
Suppress the file name prefix on output |
-H, --with-filename |
Print file name with output lines |
Examples
How to Use These Examples
The examples below show common ways to use the fgrep
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
fgrep "search string" filename.txt