15 practical grep command examples in linux : unix

chinkshady 2,053 views 22 slides Apr 18, 2012
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

No description available for this slideshow.


Slide Content

35
53Like
Home
About
Free+eBook
Archives
Best+of+the+Blog
Contact
15#Prac(cal#Grep#Command#Examples#In#Linux#/#UNIX
by+ SathiyaMoorthy +on+ March+26,+2009
Tw e e t
Tw e e t
36
Photo+courtesy+of+ Alexôme’s
You+should+get+a+grip+on+the+Linux+grep+command.
This+is+part+of+the+onKgoing+15+Examples+series,+where+15+detailed+examples+will+be+p rovided+for+a+specific+command+or+funcQonality.+
Earlier+we+discussed+15+pracQcal+examples+for+Linux+ find+command ,++Linux+ command+line+history +and+ mysqladmin+command .
In+this+arQcle+let+us+review+15+pracQcal+examples+of+Linux+grep+command+that+will+be+ very+useful+to+both+newbies+and+experts.
First+create+the+following+demo_file+that+will+be+used+in+the+examples+below+to+demons trate+grep+command.
$ cat demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
1+of+22 18+Apr+12+7:31+pm

this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line.
1.#Search#for#the#given#string#in#a#single#file
The+basic+usage+of+grep+command+is+to+search+for+a+specific+string+in+the+specified+file +as+shown+below.
Syntax:
grep "literal_string" filename
$ grep "this" demo_file
this line is the 1st lower case line in this file.
Two lines above this line is empty.
2.#Checking#for#the#given#string#in#mul(ple#files.
Syntax:
grep "string" FILE_PATTERN
This+is+also+a+basic+usage+of+grep+command.+For+this+example,+let+us+copy+the+demo_fil e+to+demo_file1.+The+grep+output+will+also+include
the+file+name+in+front+of+the+line+that+matched+the+specific+paZern+as+shown+below.+Whe n+the+Linux+shell+sees+the+meta+character,+it+does
the+expansion+and+gives+all+the+files+as+input+to+grep.
$ cp demo_file demo_file1
$ grep "this" demo_*
demo_file:this line is the 1st lower case line in this file.
demo_file:Two lines above this line is empty.
demo_file:And this is the last line.
demo_file1:this line is the 1st lower case line in this file.
demo_file1:Two lines above this line is empty.
demo_file1:And this is the last line.
3.#Case#insensi(ve#search#using#grep#Hi
Syntax:
grep -i "string" FILE
This+is+also+a+basic+usage+of+the+grep.+This+searches+for+the+given+string /paZern+cas e+insensiQvely.+So+it+matches+all+the+words+such+as+“the”,
“ THE”+and+“ The”+case+insensiQvely+as+shown+below.
$ grep -i "the" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
And this is the last line.
4.#Match#regular#expression#in#files
Syntax:
grep "REGEX" filename
This+is+a+very+powerful+feature,+if+you+can+use+use+regular+expression+effecQvely.+In+ the+following+example,+it+searches+for+all+the+paZern
that+starts+with+“lines”+and+ends+with+“empty ”+with+anything+inKbetween.+i.e+To+searc h+“lines[anything+inKbetween]empty ”+in+the
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
2+of+22 18+Apr+12+7:31+pm

demo_file.
$ grep "lines.*empty" demo_file
Two lines above this line is empty.
From+documentaQon+of+grep:+A+regular+expression+may+be+followed+by+one+of+several+rep eQQon+operators:
?+The+preceding+item+is+opQonal+and+matched+at+most+once.
*+The+preceding+item+will+be+matched+zero+or+more+Qmes.
++The+preceding+item+will+be+matched+one+or+more+Qmes.
{n}+The+preceding+item+is+matched+exactly+n+Qmes.
{n,}+The+preceding+item+is+matched+n+or+more+Qmes.
{,m}+The+preceding+item+is+matched+at+most+m+Qmes.
{n,m}+The+preceding+item+is+matched+at+least+n+Qmes,+but+not+more+than+m+Qmes.
5.#Checking#for#full#words,#not#for#subHstrings#using#grep#Hw
If+you+want+to+search+for+a+word,+and+to+avoid+it+to+match+the+substrings+use+Kw+opQo n.+Just+doing+out+a+normal+search+will+show+out+all+the
lines.
The+following+example+is+the+regular+grep+where+it+is+searching+for+“is”.+When+you+se arch+for+“is”,+without+any+opQon+it+will+show+out+“is”,
“his”,+“this”+and+everything+which+has+the+substring+“is”.
$ grep -i "is" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line.
The+following+example+is+the+WORD+grep+where+it+is+searching+only+for+the+word+“is”.+ Please+note+that+this+output+does+not+contain+the+line
“ This+Line+Has+All+Its+First+Character+Of+The+Word+With+Upper+Case”,+even+though+“is” +is+there+in+the+“ This”,+as+the+following+is+looking+only
for+the+word+“is”+and+not+for+“this”.
$ grep -iw "is" demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
Two lines above this line is empty.
And this is the last line.
6.#Displaying#lines#before/aQer/around#the#match#using#grep#HA,#HB#and#HC
When+doing+a+grep+on+a+huge+file,+it+may+be+useful+to+see+some+lines+aoer+the+match.+Y ou+might+feel+handy+if+grep+can+show+you+not+only
the+matching+lines+but+also+the+lines+aoer/before/around+the+match.
Please+create+the+following+demo_text+file+for+this+example.
$ cat demo_text
4. Vim Word Navigation
You may want to do several navigation in relation to the words, such as:
* e - go to the end of the current word.
* E - go to the end of the current WORD.
* b - go to the previous (before) word.
* B - go to the previous (before) WORD.
* w - go to the next word.
* W - go to the next WORD.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
3+of+22 18+Apr+12+7:31+pm

WORD - WORD consists of a sequence of non-blank characters, separated with white spac e.
word - word consists of a sequence of letters, digits and underscores.
Example to show the difference between WORD and word
* 192.168.1.1 - single WORD
* 192.168.1.1 - seven words.
6.1#Display#N#lines#aQer#match
KA+is+the+opQon+which+prints+the+specified+N+lines+aoer+the+match+as+shown+below.
Syntax:
grep -A <N> "string" FILENAME
The+following+example+prints+the+matched+line,+along+with+the+3+lines+aoer+it.
$ grep -A 3 -i "example" demo_text
Example to show the difference between WORD and word
* 192.168.1.1 - single WORD
* 192.168.1.1 - seven words.
6.2#Display#N#lines#before#match
KB+is+the+opQon+which+prints+the+specified+N+lines+before+the+match.
Syntax:
grep -B <N> "string" FILENAME
When+you+had+opQon+to+show+the+N+lines+aoer+match,+you+have+the+KB+opQon+for+the+oppo site.
$ grep -B 2 "single WORD" demo_text
Example to show the difference between WORD and word
* 192.168.1.1 - single WORD
6.3#Display#N#lines#around#match
KC+is+the+opQon+which+prints+the+specified+N+lines+before+the+match.+In+some+occasion+ you+might+want+the+match+to+be+appeared+with+the
lines+from+both+the+side.+This+opQons+shows+N+lines+in+both+the+side(before+&+aoer)+o f+match.
$ grep -C 2 "Example" demo_text
word - word consists of a sequence of letters, digits and underscores.
Example to show the difference between WORD and word
* 192.168.1.1 - single WORD
7.#Highligh(ng#the#search#using#GREP_OPTIONS
As+grep+prints+out+lines+from+the+file+by+the+paZern+/+string+you+had+given,+if+you+wa nted+it+to+highlight+which+part+matches+the+line,+then
you+need+to+follow+the+following+way.
When+you+do+the+following+export+you+will+get+the+highlighQng+of+the+matched+searches .+In+the+following+example,+it+will+highlight+all+the
this+when+you+set+the+GREP_OPTIONS+environment+variable+as+shown+below.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
4+of+22 18+Apr+12+7:31+pm

$ export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8'
$ grep this demo_file
this line is the 1st lower case line in this file.
Two lines above this line is empty.
And this is the last line.
8.#Searching#in#all#files#recursively#using#grep#Hr
When+you+want+to+search+in+all+the+files+under+the+current+directory+and+its+sub+direc tory.+Kr+opQon+is+the+one+which+you+need+to+use.+The
following+example+will+look+for+the+string+“ramesh”+in+all+the+files+in+the+current+di rectory+and+all+it ’s+subdirectory.
$ grep -r "ramesh" *
9.#Invert#match#using#grep#Hv
You+had+different+opQons+to+show+the+lines+matched,+to+show+the+lines+before+match,+an d+to+show+the+lines+aoer+match,+and+to+highlight
match.+So+definitely+You’d+also+want+the+opQon+Kv+to+do+invert+match.
When+you+want+to+display+the+lines+which+does+not+matches+the+given+string /paZern,+us e+the+opQon+Kv+as+shown+below.+This+example+will
display+all+the+lines+that+did+not+match+the+word+“go”.
$ grep -v "go" demo_text
4. Vim Word Navigation
You may want to do several navigation in relation to the words, such as:
WORD - WORD consists of a sequence of non-blank characters, separated with white spac e.
word - word consists of a sequence of letters, digits and underscores.
Example to show the difference between WORD and word
* 192.168.1.1 - single WORD
* 192.168.1.1 - seven words.
10.#display#the#lines#which#does#not#matches#all#the#given#pa]ern.
Syntax:
grep -v -e "pattern" -e "pattern"
$ cat test-file.txt
a
b
c
d
$ grep -v -e "a" -e "b" -e "c" test-file.txt
d
11.#Coun(ng#the#number#of#matches#using#grep#Hc
When+you+want+to+count+that+how+many+lines+matches+the+given+paZern/string,+then+use+ the+opQon+Kc.
Syntax:
grep -c "pattern" filename
$ grep -c "go" demo_text
6
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
5+of+22 18+Apr+12+7:31+pm

When+you+want+do+find+out+how+many+lines+matches+the+paZern
$ grep -c this demo_file
3
When+you+want+do+find+out+how+many+lines+that+does+not+match+the+paZern
$ grep -v -c this demo_file
4
12.#Display#only#the#file#names#which#matches#the#given#pa]ern#using#grep#Hl
If+you+want+the+grep+to+show+out+only+the+file+names+which+matched+the+given+paZern,+u se+the+Kl+(lowerKcase+L)+opQon.
When+you+give+mulQple+files+to+the+grep+as+input,+it+displays+the+names+of+file+which+c ontains+the+text+that+matches+the+paZern,+will+be
very+handy+when+you+try+to+find+some+notes+in+your+whole+directory+structure.
$ grep -l this demo_*
demo_file
demo_file1
13.#Show#only#the#matched#string
By+default+grep+will+show+the+line+which+matches+the+given+paZern/string,+but+if+you+ want+the+grep+to+show+out+only+the+matched+string+of
the+paZern+then+use+the+Ko+opQon.
It+might+not+be+that+much+useful+when+you+give+the+string+straight+forward.+But+it+be comes+very+useful+when+you+give+a+regex+paZern+and
trying+to+see+what+it+matches+as
$ grep -o "is.*line" demo_file
is line is the 1st lower case line
is line
is is the last line
14.#Show#the#posi(on#of#match#in#the#line
When+you+want+grep+to+show+the+posiQon+where+it+matches+the+paZern+in+the+file,+use+th e+following+opQons+as
Syntax:
grep -o -b "pattern" file
$ cat temp-file.txt
12345
12345
$ grep -o -b "3" temp-file.txt
2:3
8:3
Note: +The+output+of+the+grep+command+above+is+not+the+posiQon+in+the+line,+it+is+byte+offse t+of+the+whole+file.
15.#Show#line#number#while#displaying#the#output#using#grep#Hn
To+show+the+line+number+of+file+with+the+line+matched.+It+does+1Kbased+line+numbering+ for+each+file.+Use+Kn+opQon+to+uQlize+this+feature.
$ grep -n "go" demo_text
5: * e - go to the end of the current word.
6: * E - go to the end of the current WORD.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
6+of+22 18+Apr+12+7:31+pm

35
Tw e e t
Tw e e t
36
53Like
+Share
7: * b - go to the previous (before) word.
8: * B - go to the previous (before) WORD.
9: * w - go to the next word.
10: * W - go to the next WORD.
Addi(onal#Grep#Tutorials
7+Linux+Grep+OR,+Grep+AND,+Grep+NOT+Operator+Examples
Regular+Expressions+in+Grep+Command+with+10+Examples+–+Part+I
Advanced+Regular+Expressions+in+Grep+Command+with+10+Examples+–+Part+II
Search+in+a+*.bz2+file+using+ bzg re p ,+and+*.gz+file+using+ zgrep
Awesome#Linux#Ar(cles
Following+are+few+awesome+ 15#examples +arQcles+that+you+might+find+helpful.
Linux+Crontab:+15+Awesome+Cron+Job+Examples
Mommy,+I+found+it!+—+15+PracQcal+Linux+Find+Command+Examples
15+Examples+To+Master+Linux+Command+Line+History
Unix+LS+Command:+15+PracQcal+Examples
+Comment
If#you#enjoyed#this#ar(cle,#you#might#also#like..
50+Linux+Sysadmin+Tutorials1.
50+Most+Frequently+Used+Linux+Commands+(With+Examples)2.
Top+25+Best+Linux+Performance+Monitoring+and+Debugging+Tools3.
Mommy,+I+found+it!+–+15+PracQcal+Linux+Find+Command
Examples
4.
Linux+101+Hacks+2nd+EdiQon+eBook +5.
Awk+IntroducQon+–+7+Awk+Print+Examples
Advanced+Sed+SubsQtuQon+Examples
8+EssenQal+Vim+Editor+NavigaQon+Fundamentals
25+Most+Frequently+Used+Linux+IPTables+Rules
Examples
Turbocharge+PuT TY+with+12+Powerful+AddKOns
Ta g s : + File+Search+UQlity ,+ Grep+Command ,+ Highlight+Search+Output ,+ Linux+FullKText+Searching ,+ Linux+Grep+Command ,+ Search+File+Content ,
Search+MulQple+Files
{ +71 +comments…+read+them+below+or+ add+one +}
1 +Joao+Trindade +March+28,+2009+at+3:54+am
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
7+of+22 18+Apr+12+7:31+pm

You+have+a+small+glitch:
>>+4.+Match+regular+expression+in+files+using+grep+Ki
Don’t+you+mean:
4.+Match+regular+expression+in+files+using+grep+Ke
The+rest+of+the+post+is+great.
2 +Ramesh +March+29,+2009+at+12:16+am
Joao,
Thanks+for+poinQng+it+out.+I+have+corrected+it.+Also,+we+can+do+REGEX+without+the+opQ on+Ke+as+shown+in+the+example+#4.

From+Man+Pages:
SYNOPSIS
grep [options] PATTERN [FILE...]
grep [options] [-e PATTERN | -f FILE] [FILE...]
-e PATTERN, --regexp=PATTERN
Use PATTERN as the pattern; useful to protect patterns beginning with -.
3 +dragon +March+31,+2009+at+11:26+pm
Hi:
FYI,+Qp+14+will+be
2:3
8:3
on+Ubuntu+system.+(including+the+\n+character+I+guess
4 +Ramesh +March+31,+2009+at+11:44+pm
Dragon,
Thanks+for+poinQng+it+out.+I’ve+corrected+it.
5 +Francesco+Talamona +April+26,+2009+at+2:48+am
I+find+very+useful+the+following+command,+when+you+have+to+deal+with+a+very+lengthy+co nfiguraQon+file+full+of+comments:
grep+Kv+KE+‘^\#|^$’+/etc/squid/squid.conf
It+skips+every+line+beginning+with+an+hash+(#)+or+empty,+so+you+can+see+at+a+glance+t he+15+lines+edited+out+of+a++4400+lines+text+file.
BTW+interesQng+topics,+great+posts…
6 +albar +May+7,+2009+at+7:51+pm
help+me
how+to+bzgrep+:+^C02
but+^C+is+count+as+one+special+character,
in+this+word:
data1^C02data2
thank’s
7 +Ramesh+Natarajan +May+8,+2009+at+5:51+pm
@Francesco#Talamona,
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
8+of+22 18+Apr+12+7:31+pm

Thanks+a+lot+for+sharing+your+grep+command+example.+Yes.+all+those+empty+lines+and+co mment+lines+can+get+very+annoying+when
you+do+grep.+So,+it+is+an+excellent+idea+to+hide+them+in+the+grep+output+with+your+ex amples.
8 +sasikala +May+11,+2009+at+9:41+pm
@albar,
try+like+this
grep+‘\^C02?
9 +albar +May+12,+2009+at+1:18+am
@sasikala+,
i+do+have+try+that+too,+but+sQll+got+nothing,
but+it+works+when+^+and+C+count+as+two+character
thank’s
10 +SathiyaMoorthy +May+12,+2009+at+4:33+am
@albar
You+should+type+^C+as+ctrlKv+++ctrlKc+in+grep+as+single+character+as
$+grep+^C02+file
Dont+escape,+dont+type+it+as+^+C+as+two+characters.+Hope+this+helps.
11 +albar +May+12,+2009+at+8:59+pm
@sathiya,
god+bless+u+all
it+work’s+thanks
12 +Manish+Patel +May+21,+2009+at+7:00+pm
Hi
I+am+trying+to+exclude+the+last+word+of+all+the+line+like+sync.php,+uploads.php,+back up.php
File+text+include+as+below
/usr/home/htdocs/dragKandKdrop/htdocs.php
/usr/home//htdocs/sms/publish/pages/sync.php
/usr/home/htdocs/track/backup.php
/usr/home/htdocs/smstest/smstest.php
/usr/home/htdocs/uploads.php
/usr/home/htdocs/017/backup.php
How+can+I+achieve+that+using+grep+or+sed+or+awk
Also+how+I+can+use+“*”+wildcard+in+sed+command+like+to+replace+*.php+to+*.txt+or+any+ other+extension.
Thank+you+in+advance.
Manish
13 +Francesco+Talamona +May+21,+2009+at+10:36+pm
Are+you+restricted+to+sed+or+awk?
1)
dirname+‘/usr/home/htdocs/dragKandKdrop/htdocs.php’
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
9+of+22 18+Apr+12+7:31+pm

/usr/home/htdocs/dragKandKdrop
2)
rename+does+what+you+want
14 +Manish+Patel +May+24,+2009+at+6:55+pm
Hi,
Those+lines+are+the+contents+of+the+text+file+and+I+don’t+want+to+change+the+actual+di rectory+or+the+file+on+server.+I+want+to+change
the+contents+of+the+file+where+all+file+file+names+ending+at+the+line+should+be+removed. +So+the+final+file+contents+should+look+like
this
cat+filecontenet.txt
/usr/home/htdocs/dragKandKdrop/
/usr/home//htdocs/sms/publish/pages/
/usr/home/htdocs/track/
/usr/home/htdocs/smstest/
/usr/home/htdocs/
/usr/home/htdocs/
I+think+rename+would+not+help+here+in+ediQng+file+contents.
Thank+you
Manish
15 +SathiyaMoorthy +May+24,+2009+at+11:43+pm
rev+filecontenet.txt+|+cut+Kd’/’+Kf2K+|+rev
rev+filecontenet.txt+–>+reverses+the+file+and+pipes+to+cut+command.
cut+Kd’/’+Kf2K+–>+cuts+off+the+first+field+(+cuts+off+last+field,+as+it+is+reversed+).
rev+–>+prints+the+output+given+order.
16 +P0B0T +May+26,+2009+at+11:36+pm
Manish,
I+believe+you’re+looking+for+the+following
sed+Ke+‘s/.php$//’+filecontenet.txt
17 +P0B0T +May+26,+2009+at+11:39+pm
Sorry,+didn’t+read+your+requirement+carefully.
Try+this:
sed+Ke+‘s/\/[^/]*.php$/\//’+filecontenet.txt
18 +Manish+Patel +June+5,+2009+at+5:31+pm
Hi
Thank+you+to+Sathiya+Moorthy+and+P0B0T.
Both+soluQon+worked+very+nicely+for+me.
P0B0T+can+you+explain+how+your+command+works+for+each+defined+opQon+’s/\/[^/]*.php$/\/ /’
Thank+you
Manish
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
10+of+22 18+Apr+12+7:31+pm

19 +mano +June+10,+2009+at+3:00+am
The+above+info+on+grep+is+really+great.+I+want+to+search+for+a+string+in+all+the+files +in+the+directory+and+add+a+$+symbol+at+the+start+of
the+searched+line+and+save+in+the+same+file.
20 +SathiyaMoorthy +June+18,+2009+at+10:49+pm
@mano
More+than+using+grep+for+this+requirement,+you+can+use+sed+which+is:
sed+Ki+‘s/.*abc.*/$&/’+*
Ki+:+edit+the+input+file.
s///+:+subsQtute+the+matched+paZern+with+the+replacement+string.
/.*abc.*/+:+match+the+string+abc
/$&/+:+Replace+with+$+followed+by+matched+string.
*+:+all+the+files+in+the+current+directory.
This+is+one+way+of+saQsfying+your+requirement,+there+may+be+other+efficient+ways.
Hope+this+helps.
21 +mano +June+19,+2009+at+12:17+am
Hi+SathiaMoorthy,+Thank+u+so+much.+it+works+fine.+If+I+need+to+search+for+files+in+all+ subdirectories,+how+should+this+“sed”+command
modified?
Thanks+in+advance.
mano
22 +SathiyaMoorthy +June+27,+2009+at+12:05+am
@mano
ModificaQon+in+sed+command+is+not+needed.
To+search+for+all+files+in+the+subdirectory.
find+.+Ktype+f
Execute+the+command+on+all+those+files+with+Kexec.
find+.+Ktype+f+Kexec+sed+Ki+‘s/.*abc.*/#&/’+{}+\;
But+think+twice+before+execuQng+this+command,+because+it+will+recursively+edit+all+th e+files.+Taking+backup+before+execuQng+this
command+is+wise.
Refer+the+earlier+arQcle+ linux+find+command+examples .
23 +Vidya +July+1,+2009+at+2:59+am
Hi,
I+want+to+grep+next+3+words+in+a+line+from+the+matching+criteria+word..
like+if+the+line+is
This+is+Kg+gateway+Ke+enterprise+Ks+server
Then+I+want+to+grep+“Kg+gateway+Ke+enterprise”+from+the+line
Can+you+please+help+me+in+this+case.
Here+gateway+and+enterprise+value+can+be+anything+so+need+to+grep+next+3+words+starQn g+form+“Kg ”
24 +SathiyaMoorthy +July+1,+2009+at+5:58+am
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
11+of+22 18+Apr+12+7:31+pm

@Vidhya
$+grep+Ko+KE+—+“Kg+\w++Ke+\w+”+FILENAME
Kg+gateway+Ke+enterprise
ExplanaQon+of+the+above+command.,
Ko+:+only+matching+(+point+13.+)
KE+:+extended+regexp
—+:+indicate+end+of+opQons
\w++:+word
25 +Vidya +July+1,+2009+at+9:00+am
Hi+Sathiya,
Its+not+working.
It+says
grep:+illegal+opQon+—+o
grep:+illegal+opQon+—+E
Usage:+grep+Khblcnsviw+paZern+file+.+.+.
I+am+working+on+Solaris+and+se?ng+shell+as+bash.
26 +Amit+Agarwal +September+21,+2009+at+6:18+am
grep+version+on+solaris+is+liZle+older+and+as+man+would+show+you+all+these+opQons+are +not+available,+so+you+can+try+ack
(standalone)+version+which+is+very+powerful+and+requires+only+perl+to+be+installed.
27 +learner +October+7,+2009+at+5:31+am
Hi,
How+to+use+grep+to+find+lines+containing+mulQple+strings
ex:+line1:Today+is+oct+7,+wednesday.+not+8th
line2:+This+is+not+summer.
line3:+when+is+summer?
I+want+to+return+line2+containing+strings+“not ”+and+“summer ”+both.
Thank+You.
28 +SathiyaMoorthy +October+7,+2009+at+10:41+am
@learner
There+are+several+ways+possible,+use+the+one+which+you+find+as+appropriate.
$ grep "not.*summer" file1
line2: This is not summer.
$ grep "not" file1 | grep "summer"
line2: This is not summer.
29 +learner +October+7,+2009+at+10:56+pm
@SathiyaMoorthy
Thank+You+for+your+very+quick+reply.
My+quesQon+was+not+piping+and+hard+coding+every+string+,+as+i+menQoned+mulQple+string s,+i+was+looking+for+something+in+likes+of
grep+KF+‘string1
string2
string3
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
12+of+22 18+Apr+12+7:31+pm

string4
…..
stringn’+filename
which+returns+single+occurrence+of+something+like+either+string1+,string2,..+stringn+ or+all+..,+what+i+wanted+was+only+string1+and
string2+and+…….+stringn+begin+returned.
[please+note+that+i+will+be+provided+with+strings+as+newline+separated+strings+,which +i+don't+want+to+parse+again+and+i+have
constraint+of+using+grep+only]
Thank+You.
30 +Ashish +December+1,+2009+at+4:07+pm
Hi,
I+need+to+sthing+like+this
I+have+a+file+containing+400+domainId+values+seprated+by+new+line
ex.+domain.txt
domain1
domain2
domain3…
I+have+a+script+that+takes+each+domain+and+calls+an+api+that+returns+me+an+xml.
like+this+for+each+domain
va l 1
domain1
va l 2
va l 3
va l 4
XXX
va l 1
now+i+want+to+spit+out+the+domain+name+in+a+file+that+does+not+matches+domainid+value+ XXX.
how+can+i+do+it+using+grep
TIA
31 +Ashish +December+1,+2009+at+4:16+pm
Hi,
I+need+to+sthing+like+this
I+have+a+file+containing+400+domainId+values+seprated+by+new+line
ex.+domain.txt
domain1
domain2
domain3…
I+have+a+script+that+takes+each+domain+and+calls+an+api+that+returns+me+an+xml.
like+this+for+each+domain
<tag1>val1</tag1>
<domain>domain1</domain>
<tag2>val2</tag2>
<tag3>val3</tag3>
<tag4>val4</tag4>
<domainid>XXX</domainid>
<tag5>val1</tag5>
now+i+want+to+spit+out+the+domain+name+in+a+file+that+does+not+matches+domainid+value+ XXX.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
13+of+22 18+Apr+12+7:31+pm

how+can+i+do+it+using+grep
TIA
32 +Varun +December+17,+2009+at+7:16+am
Hi,
The+opQons+menQoned+in+point+6+for+displaying+the+context+with+A,+B,+&+C+does+not+see m+to+work+on+Solaris+10+with+both+grep+&
egrep
Is+there+a+version+of+this+grep+available+for+Solaris?
Thank+you,
Varun.
33 +Jawn+Hewz +December+21,+2009+at+7:54+pm
Does+the+Kb+(byte+offset)+work+when+greping+binary+files?+I+do+not+get+an+offset+returne d+when+I+grep+a+binary+file,+but+I+do+when
using+a+text+file.+I+am+using+grep+under+Cygwin.
34 +fe t y +January+11,+2010+at+3:32+am
thanks+very+much+for+this+tutorial.+it+is+very+helpful..
35 +eMancu +January+24,+2010+at+12:49+pm
Awsome+tutorial!
I’m+reading+all+your+blog,+its+amazing!
36 +Raghu+Baba +January+30,+2010+at+4:44+am
Hai..+I+want+to+Parse+my+file+..+Word+to+Excel+..+so+tell+me+some+grep+&+cut+commands…
37 +Jeff+Floyd +February+1,+2010+at+6:54+pm
Whats+the+difference+between+$+grep+Kc+ill+memo+and+$+grep+Kn+ill+memo?
38 +joeq +February+4,+2010+at+3:57+am
hi
i+got+1+problem…how+can+i+find+a+numbers+like+99,000,000.95+in+my+server+database+usin g+unix+command..
tq
39 +abhishek +February+21,+2010+at+4:31+am
content+was+very+useful
40 +Anonymous +March+8,+2010+at+4:26+am
Hi,
Those+lines+are+the+contents+of+the+text+file+and+I+don’t+want+to+change+the+actual+di rectory+or+the+file+on+server.+I+want+to+change
the+contents+of+the+file+where+all+file+file+names+ending+at+the+line+should+be+removed. +So+the+final+file+contents+should+look+like
this
cat+filecontenet.txt
/usr/home/htdocs/dragKandKdrop/
/usr/home//htdocs/sms/publish/pages/
/usr/home/htdocs/track/
/usr/home/htdocs/smstest/
/usr/home/htdocs/
/usr/home/htdocs/
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
14+of+22 18+Apr+12+7:31+pm

I+think+rename+would+not+help+here+in+ediQng+file+contents.
for+this+quesQon+,+awk+really+helpful+with+single+line+command
go+to+the+current+directory
ls+Kl+|+grep+Kv+^d+|+awk+‘{print+$9}’+>+new.txt
$9+—+is+the+last+filed+which+is+filename+only+when+u+list+with+opQon+ls+Kl+,
new.txt+contains+only+the+filenames+which+you+wnated+to+filter+out
41 +skipper +March+26,+2010+at+5:54+am
nice+arQcle
42 +VIKAS +April+4,+2010+at+7:23+pm
Excellent+stuff,+just+loved+grep+KA,B,C+opQons
and
grep+Ko+“xxxx.*yyyy ”+kinda+commands.
This+will+help+me+a+lot,+I+used+awk+more+in+my+shell+scripts,+But+I+have+got+a+new+fr iend+“grep”+for+some+selecQve+prinQng+
43 +Sam +April+17,+2010+at+3:35+am
I+have+just+finish+reading+this+wonderful+arQcle.+Let+me+answer+this:
Whats+the+difference+between+$+grep+Kc+ill+memo+and+$+grep+Kn+ill+memo?
grep+Kc+return+the+number+lines+that+matched+ill+in+memo.
grep+Kn+return+the+matched+lines+with+lineKnumber+as+prefix.
44 +Chong +April+20,+2010+at+3:05+am
how+to+grep+a+statement+contain+‘*’+from+a+file+at+the+same+Qme+to+match+the+first+char acter+too.
example+the+statement+in+filename+profile.txt+:K
“Mary+stay+at+uZana*istana+with+her+grandmum”
current+grep+statement+:K
grep+“^Mary+stay+at+uZana*istana”+profile.txt
result:+no+row+matched+the+grep+statement+because+of+*
How+to+use+grep+command+for+the+combine+condiQon+of+statement+with+*+and+match+the+fr ont+word?
45 +vm +April+30,+2010+at+8:24+pm
In+bash+script+without+using+perl,+how+i+can+grep+a+number+from+a+file+if+there+exists +a+number+greater+than+80+in+that+file.
46 +palash +June+13,+2010+at+12:14+pm
grep+Kc+“paZern”+filename+returns+the+number+of+lines+that+matches+the+paZern,+even+if +the+paZern+occurred+for+more+than+one
Qme+in+any+line.+Is+there+any+opQon+to+know+how+many+Qmes+the+paZern+matched+in+a+file ?
47 +mathan +June+20,+2010+at+10:21+am
HI,
I+am+new+to+linux…
can+you+tell+me+how+to+exit+from+grep+command….
mistakenly+i+type+grep+filename
But+it ’s+nothing+shown….+pls+looking+for+quick+reply…
48 +SathiyaMoorthy +July+4,+2010+at+7:20+am
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
15+of+22 18+Apr+12+7:31+pm

@mathan
There+is+nothing+like+exiQng+from+grep.
First+argument+to+grep+is+taken+as+PAT TERN,+not+as+filename.+So+as+far+as+i+understand +it+is+waiQng+for+input+to+match.+So+just+exit
from+it+using+CTRL+D.
49 +Ross+HuggeZ +September+16,+2010+at+5:04+am
Nice+arQcle.+Thanks.
50 +ec +October+6,+2010+at+6:14+pm
Hi+to+all,
I+just+started+to+learn+linux+a+month+ago
Can+I+extract+2+to+6+leZer+words+from+a+text+file+using+one+grep+command+only!
To+menQon+that+each+word+is+on+its+own+line
what ’s+the+grep+command+to+do+this+job?
I+tried+any+combinaQon+of+grep+and+not+the+result+which+I+am+looking+for
51 +Lou +February+24,+2011+at+1:16+pm
Is+there+a+way+to+grep+for+a+word+on+in+a+file+and+return+that+line+plus+the+next?
52 +Francesco+Talamona +February+26,+2011+at+3:33+am
@+Lou:
cat+tes?ile.txt
first+line
matching+line
following+line
ending+line
grep+matching+KB+1+tes?ile.txt
first+line
matching+line
53 +abhishek+kumar +April+19,+2011+at+12:53+pm
really+to+nice+and+too+simple+to+understand,
thats+great
thank+you
54 +Nikita +April+21,+2011+at+12:06+pm
PLEASE+HELP+ON+QUESTION+B.
You+are+searching+a+file+for+lines+that+contain+US+state+abbreviaQons+in+parentheses.+ e.g.:+(ma),(NH),(Ky),+etc.+So+you+decide+to
match+any+line+containing+(+)+with+exactly+two+characters+(not+leZers)+in+between.
A)+What+grep+will+get+this+done?
My+Answer—>+grep+‘([aKzAKZ][AKZaKz])’+file
You+now+noQce+that+some+of+the+lines+that+the+grep+from+part+A+matched+contain+the+th e+string+(expired).+You+want+to+eliminate
these+lines+from+your+output,+so+you+decide+to+pipe+your+output+to+another+grep.
B)+What+will+the+new+command+be?+(both+greps+with+the+pipe)
My+Answer+—>+grep+–v+grep+|+grep+‘([aKzAKZ]+[AKZaKz])’+——K>+PLEASE+HELP!
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
16+of+22 18+Apr+12+7:31+pm

55 +Francesco+Talamona +April+22,+2011+at+12:44+pm
@Nikita:
One+step+is+enough:
egrep+‘\([aKzAKZ]{2}\)’+file
56 +suprabhat +April+27,+2011+at+3:26+am
How+to+display+all+lines+that+have+less+than+9+character+in+a+file
57 +Paul +May+16,+2011+at+3:09+pm
I’m+new+to+linux;+was+wondering+what+does+\#+aoer+the+grep+command+accomplish,+as+sho wn+in+the+example+below?
grep+\#+input*.txt+|+awk+‘{print+$4}’+|+sort+|+uniq+>+output.txt
thank+you
58 +Dinesh +May+17,+2011+at+4:03+pm
For+a+given+patern+like
Fri+Nov+26+16:04:52+2010
I+want+to+grep+for+all+the+lines+in+a+file+having+the+above+format.
But+I+have+all+the+values+except+for+the+Qme,+that+is+“16:04:52+”+,+the+data+I+have+i s
“Fri+Nov+26+2010+”+.+The+file+is+having+5+years+of+date+with+the+Qmestamp+as+specified+ above.
Please+let+me+know+How+shall+I+grep+the+file+to+get+all+the+lines+on+the+date+“Fri+Nov +26+2010+”+.
thanks
59 +shyam +May+29,+2011+at+10:45+pm
i+have+a+doubt+here+i+tried+to+look+at+output+of+cmd
grep+“[^AKZ]”+file.txt
this+is+showing+all+characters+excluding+capital+leZer
what+does+this+command+actually+do
60 +shivaraj+PaQl +July+25,+2011+at+11:14+am
HI+i+have+a+file+with+this+values
100+first+line
101+second+line
101
102
102
109
now+i+need+a+script+that+can+take+two+lines+and+find+which+is+greatest
61 +sudheer +September+10,+2011+at+8:32+pm
1)+Use+grep+(or+awk)+to+output+all+lines+in+a+given+file+which+contain+employee+ID+num bers.+Assume+that+each+employee+ID+number
consists+of+1K4+digits+followed+by+two+leZers:+the+first+is+either+a+W+or+a+S+and+the+ second+is+either+a+C+or+a+T.+ID+numbers+never
start+with+0s.+Further+assume+that+an+employee+ID+is+always+proceeded+by+some+type+of +white+space+–+tab,+blank,+new+line+etc.
However,+there+might+be+characters+aoer+it,+for+example+punctuaQon.
What+to+turn+in:+Turn+in+three+things:
a.+A+file+with+the+regular+expression+which+can+directly+be+used+by+grep+(or+awk)
b.+A+text+file+which+you+used+to+test+your+regular+expression.+Make+sure+that+you+incl ude+valid+and+‘invalid’+employee+IDs,+have
them+at+the+beginning+and+the+end+of+lines,+sentences,+etc.
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
17+of+22 18+Apr+12+7:31+pm

c.+A+second+document+which+reKwrites+the+regular+expression+in+a+more+humanKreadable+ form+and+explains+the+purpose+of+the
different+components+of+the+regular+expression.+Also+include+a+short+explanaQon+of+you r+test+cases.
2)+Use+grep+(or+awk)+to+output+all+the+lines+in+a+given+file+which+contain+a+decimal+n umber+(e.g.+a+number+which+includes+a+decimal
point).+Decimal+numbers+do+not+have+leading+zeros+but+they+might+have+trailing+zeros. +Assume+the+number+is+always+surrounded
by+white+space.
What+to+turn+in:+The+same+three+things+as+above+(except,+of+course,+for+this+problem) .
3)+Write+a+regular+expression+for+the+valid+idenQfiers+in+Java.+You+are+allowed+to+use +‘shortcuts’,+but+need+to+make+sure+that+you
specify+exactly+what+they+are+(e.g.+if+you+use+digit+specify+that+that+means+0,+1,+2, +3,+….9.)
62 +Dinesh +September+22,+2011+at+12:43+pm
Paul
grep+\#+input*.txt+|+awk+‘{print+$4}’+|+sort+|+uniq+>+output.txt
Since+#+is+a+special+character,we+are+treaQng+#+as+#+by+pu?ng+backslash+infront+of+th at.
Noe+Greap+searches+for+paZern+#+in+a+list+of+file+starQng+as+input+and+nding+a+txt+and +then+awk+prints+the+4th+field+and+sort+is+doing
sorQng+the+4th+field+returns+from+awk+and+unis+is+doing+uniq+operaQon.
63 +Dinesh +September+22,+2011+at+12:45+pm
Shyam
grep+“[^AKZ]”+file.txt
Grep+will+print+the+lines+that+does+not+start+with+CAPTIAL+LET TERS.
Using+^+inside+the+[]+will+do+the+work+opposite+to+the+paZern+what+you+have+been+sear ching+for+…
64 +haydarekarrar +December+23,+2011+at+4:29+am
Just+a+minor+thing+the+last+result+line+is+removed+in+the+example+above,+this+should+ be+the+result:
$+grep+“this”+greptest.txt
this+line+is+the+1st+lower+case+line+in+this+file.
Two+lines+above+this+line+is+empty.
And+this+is+the+last+line.
65 +gotham +January+22,+2012+at+4:32+am
awesome.+thanks+a+lot.
66 +edward +January+31,+2012+at+2:20+am
For+example+my+data+is+(file.ave)+:
MRR+120101000000+UTC+07+AVE+60+STF+150+ASL
H+150+300+450+600+750+900
TF+0.0149+0.0515+0.1171
F00+K67.04
F01+K69.27
I+use+grep+as:
grep+Kr+‘MRR’+*.ave+>+Qme_0101.txt.+In+this+case+all+file+goes+to+Qme_0101.txt,+I+have +many+files+and+I+need+each+output+goes+to
specific+file+name.+Any+idea+?+And+how+to+use+grep+to+take+F00+and+F01+?+If+I+use+grep+ Kr+‘F’+*.ave,+the+first+line+will+be+taken+also
because+of+STF,+Thanks+for+help..
67 +shrikant +February+14,+2012+at+10:23+am
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
18+of+22 18+Apr+12+7:31+pm

Thank+you+
68 +chinna +February+19,+2012+at+8:48+am
here+my+quesQon+is+in+a+directory+i+have+10+files.some+files+contains+size+in+kb’s+and+ some+files+contains+size+in+mb’s…..i+want
display+the+files+only+which+file+size+is+more+than+1+mb……
could+anybudy+help+to+find+answer+for+this+quesQon….
69 +Anderson+Venturini +March+14,+2012+at+6:01+am
Great+post!+It+was+very+useful!+thanks+a+lot!+
70 +Anonymous +April+9,+2012+at+3:22+pm
To+answer+Chinna…+If+you+have+some+files+showing+M,+and+some+K,+then+your+“ls”+command +is+probably+running+on+a+Linux+box,
and+using+the+“Kh”+opQon.
The+preferred+method+would+be+NOT+to+use+the+“Kh”+opQon,+and+let+“ls”+print+file+sizes +in+bytes,+which+means+that+your+script+will
be+able+to+get+the+same+units+detail+for+all+file+sizes+listed.
Then+you+can+use+“awk”+to+filter+out+files+where+$5+(5th+field)+is+over+1Meg,+like+this:
/bin/ls+Kl+|+awk+‘$5>=2^20?
If+you+only+want+file+names,+not+‘ls’+style+list,+then+have+awk+give+you+that+part+of+ output:
/bin/ls+Kl+|+awk+‘$5>=2^20{print+$NF}’
Note:+this+does+not+like+file+names+with+spaces…
—K
notes+for+Other+posQngs+on+this+thread:
To:+Francesco+Talamona
(who+was+using+“grep”+to+remove+##_comments+from+long+config+files)
grep+Kv+KE+‘^\#|^$’+/etc/squid/squid.conf
You+may+want+to+remove+comments+that+do+NOT+start+on+the+first+char+of+a+line,
and+‘sed’+is+more+useful+for+that
sed+‘s/#.*$//;/^[+]*$/d’+/etc/squid/squid.conf
This+will+remove+comments+from+each+line,+then+discard+the+line+if+blank,+or+only+spa ces+remain.
=========
Also,+where+the+KB+and+KA+opQons+are+described+for+“grep”…
This+is+for+GNU/Linux,+and+not+supported+for+most+NonKLinux+boxes.
#–JETS
71 +KHEE +April+15,+2012+at+8:39+pm
Hi+expert,
i+am+new+to+unix+env…
try+to+use+certain+command+to+help+me+generate+1+output+file+as+below:
input+file:
A
A/I+0.2+0.3+0.8
B
B/I+0.6+0.8+0.9
C
C+0.8+2.1+6.0
I+just+want+to+grep+all+A+B+C+only,+where+want+to+skip+the+line+which+have+the+number +together.+And+my+output+file+paZern+is+A+B+C
D…etc+(+A,+B,C+all+are+a+word).
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
19+of+22 18+Apr+12+7:31+pm

mean+i+want+first,second+line,+and+skip+3rd+&+4th+lines,+thanks+for+help.
Leave+a+Comment
Name
EK m a i l
We b s i t e
+NoQfy+me+of+followup+comments+via+eKmail
Submit
Previous+post:+ Mergecap+and+Tshark:+Merge+Packet+Dumps+and+Analyze+Network+Traffic
Next+post:+ 4+Ways+to+IdenQfy+Who+is+LoggedKIn+on+Your+Linux+System
Sign+up+for+our+free+email+newsleZer+ [email protected] +++++ Sign Up
+++++ +RS S + +Tw i Z e r + +Facebook
+ Search
EBOOKS
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
20+of+22 18+Apr+12+7:31+pm

POPULAR#POSTS
12+Amazing+and+EssenQal+Linux+Books+To+Enrich+Your+Brain+and+Library
50+UNIX+/+Linux+Sysadmin+Tutorials
50+Most+Frequently+Used+UNIX+/+Linux+Commands+(With+Examples)
How+To+Be+ProducQve+and+Get+Things+Done+Using+GTD
30+Things+To+Do+When+you+are+Bored+and+have+a+Computer
Linux+Directory+Structure+(File+System+Structure)+Explained+with+Examples
Linux+Crontab:+15+Awesome+Cron+Job+Examples
Get+a+Grip+on+the+Grep!+–+15+PracQcal+Grep+Command+Examples
Unix+LS+Command:+15+PracQcal+Examples
15+Examples+To+Master+Linux+Command+Line+History
Top+10+Open+Source+Bug+Tracking+System
Vi+and+Vim+Macro+Tutorial:+How+To+Record+and+Play
Mommy,+I+found+it!+KK+15+PracQcal+Linux+Find+Command+Examples
15+Awesome+Gmail+Tips+and+Tricks
15+Awesome+Google+Search+Tips+and+Tricks
RAID+0,+RAID+1,+RAID+5,+RAID+10+Explained+with+Diagrams
Can+You+Top+This?+15+PracQcal+Linux+Top+Command+Examples
Top+5+Best+System+Monitoring+Tools
Top+5+Best+Linux+OS+DistribuQons
How+To+Monitor+Remote+Linux+Host+using+Nagios+3.0
Awk+IntroducQon+Tutorial+–+7+Awk+Print+Examples
How+to+Backup+Linux?+15+rsync+Command+Examples
The+UlQmate+Wget+Download+Guide+With+15+Awesome+Examples
Top+5+Best+Linux+Text+Editors
Packet+Analyzer:+15+TCPDUMP+Command+Examples
The+UlQmate+Bash+Array+Tutorial+with+15+Examples
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
21+of+22 18+Apr+12+7:31+pm

3+Steps+to+Perform+SSH+Login+Without+Password+Using+sshKkeygen+&+sshKcopyKid
Unix+Sed+Tutorial:+Advanced+Sed+SubsQtuQon+Examples
UNIX+/+Linux:+10+Netstat+Command+Examples
The+UlQmate+Guide+for+CreaQng+Strong+Passwords
6+Steps+to+Secure+Your+Home+Wireless+Network
Turbocharge+PuT TY+with+12+Powerful+AddKOns
About#The#Geek#Stuff
+My+name+is+ Ramesh#Natarajan .+I+will+be+posQng+instrucQon+guides,+howKto,+troubleshooQng+Qps+and+tricks+on
Linux,+database,+hardware,+security+and+web.+My+focus+is+to+write+arQcles+that+will+e ither+teach+you+or+help+you+resolve+a+problem.
Read+more+about+ Ramesh+Natarajan +and+the+blog.
Support#Us
Support+this+blog+by+purchasing+one+of+my+ebooks.
Bash+101+Hacks+eBook
Sed+and+Awk+101+Hacks+eBook
Vim+101+Hacks+eBook
Nagios+Core+3+eBook
Contact#Us
Email#Me#: +Use+this+ Contact+Form +to+get+in+touch+me+with+your+comments,+quesQons+or+suggesQons+about+this+site.+You+c an+also
simply+drop+me+a+line+to+say+hello!.
Follow+us+on+TwiZer
Become+a+fan+on+Facebook ++
Copyright+©+2008–2012+Ramesh+Natarajan.+All+rights+reserved+|+ Te r m s + o f + S e r v i c e +|+ AdverQse
15+PracQcal+Grep+Command+Examples+In+Linux+/+UNIX hZp://www.thegeekstuff.com/2009/03/15KpracQcalKunixKgrep...
22+of+22 18+Apr+12+7:31+pm
Tags