The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep for pattern aemunathan Shell Programming and Scripting 12 05-08-2008 11:58 PM
How to grep this pattern?? askumarece Shell Programming and Scripting 13 02-20-2008 03:03 AM
help with grep the pattern bluemoon1 Shell Programming and Scripting 2 09-20-2007 08:27 AM
grep for more than one pattern frustrated1 Shell Programming and Scripting 4 12-13-2005 09:49 AM
grep and sed to find a pattern and add newline ssikhar Shell Programming and Scripting 5 10-26-2004 02:32 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-21-2007
Registered User
 

Join Date: Aug 2007
Posts: 40
grep the pattern followed by newline

Hi
I have a problem using grep to find a pattern followed by newline.
Here is my file
xxxxxxxxxxxpattern
patternxxxxxx
pattern
xxxpattern
xxpatternx
xxxxxxyyyyxxxx


I want the result to be like this
xxxxxxxxxxxpattern
pattern
xxxpattern

Please help
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-21-2007
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
Just add a '$' at the end of your pattern to match the end of the line:

grep "pattern$"
Reply With Quote
  #3 (permalink)  
Old 08-21-2007
Registered User
 

Join Date: Aug 2007
Posts: 40
Thanks a lot that works
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0