Forrest logo
tool overview
On this page you find all important commands for the CLI tool fgrep. If the command you are looking for is missing please ask our AI.

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:

  1. 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.

  2. Speed: Since fgrep does not involve the complexity of pattern matching, it can perform searches quickly, making it ideal for large files.

  3. File input: By default, fgrep reads from standard input, but it can also accept one or more file arguments to search within specific files.

  4. 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.

  5. Simple syntax: The basic syntax of fgrep is fgrep [options] pattern [file...], where pattern is the fixed string(s) to search for and file (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 machine
    explain 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 machine
    explain this command
  • fgrep:tldr:45fa3 fgrep: Display all lines except those that contain the search string.
    $ fgrep -v ${search_string} ${filename}
    try on your machine
    explain 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 machine
    explain 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 machine
    explain this command
  • fgrep:tldr:e2dcf fgrep: Search for an exact string in a file.
    $ fgrep ${search_string} ${filename}
    try on your machine
    explain this command
tool overview