Linux Grep Command

Grep command stands for Global Regular Expression Printthis command looks inside the file and display a text by searching.this command are used many options like -i and more options used this command the following example and discription of this command.

Syntax

$grep [option] [text or pattern to be searched] [file_name]

Example

 
$grep "tutorialsstudio" file1.txt
							

it will display the whole statement,containing a text(pattern) "tutorialsstudio" inside file1.txt(Searching text will be highlighted).note that,it will follow the case according to your searching text,like here tutorialsstudio keyword will be found with starting "t".


Sr.No

Options

Descriptions

01

-i

for ignoring the case,while searching the text from file.

02

-c

for counting the number of line containing a pattern or text.

03

-w

match whole word only(ex. searching for exact word "is".if any word contains substring "is" will not be considered).

04

-r

recursive searching.(it is used,when you want to search in all the file inside a directory)

05

-n

shows line number while displaying the output.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!