Perl : lines contains only Aug but not Augest


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl : lines contains only Aug but not Augest
# 1  
Old 09-04-2012
Perl : lines contains only Aug but not Augest

I am trying to write an perl regular expression to print only the lines containing Aug.

The lines in a file may contain Augest,Aug anything.
But it should only print the lines that contain Aug.
Code:
sample.txt
Tue Aug  7 03:54:12 2012
Tuesday Augest  31 03:54:12 2011
Tuesday Auge  31 03:54:12 2011

But if I use the below expression, it is treating that contains the text Aug including Augest,Aug also. But I need only the lines that contain Aug
if( $line=~/Aug/i)

Could anyone please help on this?

Thanks in advance...

Regards,
GS
# 2  
Old 09-04-2012
perl

Hi,

Check this out,

Code:
if( $line=~/\sAug\s/i)

Cheers,
Ranga Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Split lines into array - variable line items - variable no of lines.

Hi, I have the following lines that I would like to see in an array for easy comparisons and printing: Example 1: field1,field2,field3,field4,field5 value1,value2,value3,value4,value5Example 2: field1,field3,field4,field2,field5,field6,field7... (7 Replies)
Discussion started by: ejdv
7 Replies

2. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

3. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

4. Shell Programming and Scripting

[Perl] Insert lines before lines.

Hi, New problem, or challenge as they prefer in the US. I need to insert some lines in a file before certain other lines. To make it more clear: Original file: aaaa bbbbb ccccc ddddd bbbbb fffff ggggg Now I want to insert the line "NEW_NEW_NEW" when I match "fffff", but I want... (7 Replies)
Discussion started by: ejdv
7 Replies
Login or Register to Ask a Question