2020-04-23 20:18:23 +01:00
|
|
|
# fgrep
|
|
|
|
|
2021-09-01 13:57:20 +01:00
|
|
|
> Matches fixed strings in files.
|
|
|
|
> Equivalent to `grep -F`.
|
|
|
|
> More information: <https://www.gnu.org/software/grep/manual/grep.html>.
|
2020-04-23 20:18:23 +01:00
|
|
|
|
|
|
|
- Search for an exact string in a file:
|
|
|
|
|
|
|
|
`fgrep {{search_string}} {{path/to/file}}`
|
|
|
|
|
|
|
|
- Search only lines that match entirely in files:
|
|
|
|
|
2023-11-26 17:01:32 +00:00
|
|
|
`fgrep -x {{search_string}} {{path/to/file1}} {{path/to/file2}}`
|
2020-04-23 20:18:23 +01:00
|
|
|
|
|
|
|
- Count the number of lines that match the given string in a file:
|
|
|
|
|
|
|
|
`fgrep -c {{search_string}} {{path/to/file}}`
|
|
|
|
|
|
|
|
- Show the line number in the file along with the line matched:
|
|
|
|
|
|
|
|
`fgrep -n {{search_string}} {{path/to/file}}`
|
|
|
|
|
2021-09-01 13:57:20 +01:00
|
|
|
- Display all lines except those that contain the search string:
|
2020-04-23 20:18:23 +01:00
|
|
|
|
2021-09-01 13:57:20 +01:00
|
|
|
`fgrep -v {{search_string}} {{path/to/file}}`
|
2020-04-23 20:18:23 +01:00
|
|
|
|
2021-09-01 13:57:20 +01:00
|
|
|
- Display filenames whose content matches the search string at least once:
|
2020-04-23 20:18:23 +01:00
|
|
|
|
2021-09-01 13:57:20 +01:00
|
|
|
`fgrep -l {{search_string}} {{path/to/file1}} {{path/to/file2}}`
|