On Unix-like operating systems, the fgrep command searches for fixed-character strings in a file or files. “Fixed-character” means the string is interpreted literally — metacharacters do not exist, and therefore regular expressions cannot be used.
This page covers the GNU/Linux version of fgrep.
Description
fgrep is useful when you need to search for strings which contain lots of regular expression metacharacters, such as “$”, “^”, etc. By specifying that the search string contains fixed characters, you don’t need to escape each of them with a backslash.
- Description
- Syntax
- Examples
- Related commands
- Linux commands help
If your string contains newlines, each line will be considered an individual fixed-character string to be matched in the search.
Running fgrep is the same as running grep with the -F option.
Syntax
fgrep [-b] [-c] [-h] [-i] [-l] [-n] [-s] [-v] [-x] [ -e pattern_list] [-f pattern-file] [pattern] [file]
Options
Examples
fgrep “support” myfile.txt
Search for “support” in the file myfile.txt.
Related commands
ed — A simple text editor.egrep — Filter text which matches an extended regular expression.grep — Filter text which matches a regular expression.sed — A utility for filtering and transforming text.sh — The Bourne shell command interpreter.