Register
It is currently Wed Aug 20, 2014 4:43 am

Grep Question


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Feb 10, 2010 4:08 am   

Joined: Tue Feb 02, 2010 4:10 pm
Posts: 3
I'm writeing a bash script and can seem the answer to following.
Code:
if grep  $rcptno /home/joe/$rcptno -z
then echo "Duplicate Serial#"
fi

I only want to return lines that equal my variable exact as is now stands it returns if ANY art of the variable matches in the file.

Thanks,
Joe


Top
 Profile  
 PostPosted: Wed Feb 10, 2010 5:46 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Most versions of grep can use extended regular expressions so if your variable contains the whole contents of a line the following may do...

Code:
grep -zE "^$rcptno$" /home/joe/$rcptno


I've not tried this when the lines are separated with null so you may have to find the match for a null rather than using the EOL match ($)

DW


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP