From 6983b7b90a1817117cf7a8c45fdc1d2e04bf7592 Mon Sep 17 00:00:00 2001 From: Hizenberg469 Date: Mon, 25 Aug 2025 15:24:20 +0530 Subject: [PATCH] grep added --- shell/grep.txt | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 shell/grep.txt diff --git a/shell/grep.txt b/shell/grep.txt new file mode 100644 index 0000000..6cf1b7a --- /dev/null +++ b/shell/grep.txt @@ -0,0 +1,67 @@ +Grep: +(Global regular expression print) +----------------------------------- + +Purpose: + The purpose of grep is to search for text within file. + + +To use grep: + + Print the content of the file using cat command and pipe it + to grep command. + + cat | grep + + Pass the string pattern as an argument to search for it in the file. + + * To search for anything except the + + cat | grep -v + + -v : excluding the and searching everything else. + +* To search using grep without using cat command. + + Use command: + + grep + + This gives same output as it will show if we use it with cat command. + +* To mention the line number for each searched and found in the file. + + Use command: + + grep -n + +* To get only the count of the occurences of the in the + + Use command: + + grep -c + + +NOTE: + +Grep is case sensitive for the we use for searching. + + +* To Ignore the case sensitivity. + + Use command: + + grep -i + +* To look through every file in the given directory where grep is executed. + + Use command: + + grep * + +* To know where the particular pattern are present without knowing the particular file + and directory. + + Use command: + + grep -r