fgrep
The fgrep
command line tool stands for "fixed grep" or "fast grep." It is a simple and efficient command used for searching files or standard input for a fixed string or a pattern of fixed strings.
Unlike regular expressions used in grep
, fgrep
treats the text pattern as plain text, without any pattern matching or special characters. This makes it faster and more convenient for searching literal strings.
Here are some key features of fgrep
:
-
Searching:
fgrep
searches for the exact fixed pattern or a set of fixed patterns within files or input. It does not interpret or expand regular expressions. -
Speed: Since
fgrep
does not involve the complexity of pattern matching, it can perform searches quickly, making it ideal for large files. -
File input: By default,
fgrep
reads from standard input, but it can also accept one or more file arguments to search within specific files. -
Output: When a match is found,
fgrep
displays the entire line containing the matching pattern. It provides additional options to customize the output, such as showing line numbers or displaying only the matched parts. -
Simple syntax: The basic syntax of
fgrep
isfgrep [options] pattern [file...]
, wherepattern
is the fixed string(s) to search for andfile
(optional) is the file to search within.
Overall, fgrep
is a handy utility that offers a fast and straightforward way to search for fixed patterns within files or input, without the need for complex regular expressions.
List of commands for fgrep:
-
fgrep:tldr:1e943 fgrep: Search only lines that match entirely in files.$ fgrep -x ${filename1} ${filename2}try on your machineexplain this command
-
fgrep:tldr:44066 fgrep: Count the number of lines that match the given string in a file.$ fgrep -c ${search_string} ${filename}try on your machineexplain this command
-
fgrep:tldr:45fa3 fgrep: Display all lines except those that contain the search string.$ fgrep -v ${search_string} ${filename}try on your machineexplain this command
-
fgrep:tldr:b0f2e fgrep: Show the line number in the file along with the line matched.$ fgrep -n ${search_string} ${filename}try on your machineexplain this command
-
fgrep:tldr:cd379 fgrep: Display filenames whose content matches the search string at least once.$ fgrep -l ${search_string} ${filename1} ${filename2}try on your machineexplain this command
-
fgrep:tldr:e2dcf fgrep: Search for an exact string in a file.$ fgrep ${search_string} ${filename}try on your machineexplain this command