This document provides an overview of the grep command in bash shell scripting, which is used to search for strings in files. It outlines the basic syntax and various options available for the grep command, including both basic and advanced options. The document emphasizes how these options can be utilized to automate common tasks in scripting.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
7 views4 pages
1.document Grep Command Part 1
This document provides an overview of the grep command in bash shell scripting, which is used to search for strings in files. It outlines the basic syntax and various options available for the grep command, including both basic and advanced options. The document emphasizes how these options can be utilized to automate common tasks in scripting.
Learn how to automate common tasks using bash shell scripting
Grep command with basic options Basic options: -i -w -v -o -n -c -A -B -C -r -l -h grep “string/pattern” file/files grep [options] “string/pattern” file/files -i To ignore case for matching/searching -w To match a whole word -v To display the lines which are not having given string or text -o To print/display only matched parts from matched lines -n To display the matched line numbers -c To display matched number of lines -A To display N lines after match (grep –A 3 “string” file) -B To display N lines before match -C To display N lines around match -r To search under current directory and its sub-directory -l To display only file names -h To hide file names Learn how to automate common tasks using bash shell scripting