![Forrest logo](/images/logo.png)
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
The fgrep
command searches for a given string in a specified file(s) and returns the lines containing the string. Here's a breakdown of the command syntax:
fgrep
: This is the command itself. It stands for "fixed grep" and is used to search for exact, fixed strings.-n
: This option is used to display line numbers along with the matching lines. It helps in identifying the position of the string within the file.${search_string}
: This is a placeholder for the string you want to search for. You should replace${search_string}
with the actual string you want to find.${filename}
: This is a placeholder for the name of the file(s) you want to search within. You need to replace${filename}
with the actual file name or a wildcard pattern if searching in multiple files.
To use this command, you would replace ${search_string}
with the desired string and ${filename}
with the name of the file(s) to search in. For example:
fgrep -n "example" file.txt
This command would search for the string "example" in the file named file.txt
and display the matching lines with line numbers.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.