![Forrest logo](/images/logo.png)
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
The command "fgrep -l ${search_string} ${filename1} ${filename2}" is used to search for a specific search string within one or multiple files and display the names of the files that contain the search string.
Here's what each part of the command does:
- "fgrep" stands for "fixed string grep" and is a command-line utility used for searching plain-text patterns in files.
- "-l" is an option that instructs fgrep to only display the names of the files that contain the search string, rather than showing the actual lines with the matching patterns.
- "${search_string}" is a placeholder for the actual text you want to search for. Replace it with the desired string or pattern.
- "${filename1} ${filename2}" are placeholders for the names of the files you want to search within. You can replace them with the actual file names or provide multiple filenames with spaces in between.
For example, let's say you want to search for the string "example" in the files "file1.txt" and "file2.txt". The command would be:
fgrep -l "example" file1.txt file2.txt
The output will be the names of the files that contain the string "example", if there are any.
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.