Searches a file for a literal string. The fgrep command differs from the grep and egrep commands because it searches for a string instead of searching for a pattern that matches an expression.

# To search for an exact string in a file:
fgrep <search_string> <path/to/file>

# To search only lines that match entirely in files:
fgrep -x <path/to/file1> <path/to/file2>

# To count the number of lines that match the given string in a file:
fgrep -c <search_string> <path/to/file>

# To show the line number in the file along with the line matched:
fgrep -n <search_string> <path/to/file>

# To display all lines except those that contain the given regular expression:
fgrep -v <^regex$> <path/to/file>

# To display filenames whose content matchs the regular expression at least once:
fgrep -l <^regex$> <path/to/file1> <path/to/file2>