From 01e670afede63c6fc63bcc1127c6c5f0d69623ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Soto=20Valero?= Date: Thu, 23 Apr 2020 21:18:23 +0200 Subject: [PATCH] fgrep: add page (#4001) --- pages/common/fgrep.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pages/common/fgrep.md diff --git a/pages/common/fgrep.md b/pages/common/fgrep.md new file mode 100644 index 000000000..1470ad4f5 --- /dev/null +++ b/pages/common/fgrep.md @@ -0,0 +1,28 @@ +# fgrep + +> Matches patterns in files. +> Supports simple patterns and regular expressions. + +- Search for an exact string in a file: + +`fgrep {{search_string}} {{path/to/file}}` + +- Search only lines that match entirely in files: + +`fgrep -x {{path/to/file1}} {{path/to/file2}}` + +- 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}}` + +- Display all lines except those that contain the given regular expression: + +`fgrep -v {{^regex$}} {{path/to/file}}` + +- Display filenames whose content matchs the regular expression at least once: + +`fgrep -l {{^regex$}} {{path/to/file1}} {{path/to/file2}}`