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 help flood Shell Programming and Scripting 3 06-05-2008 10:14 PM
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 04:10 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 01:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-24-2006 09:20 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-07-2008
Registered User
 

Join Date: Jul 2007
Posts: 110
help on grep

Hi ALL,

I have a text file with many lines containing ------- (1 or more hyphens) and i need to remove them.

i used grep -v "-----" <file1> > <file2> BUT it does not work as hyphen exists. i tried \ (backslash) for escape sequence and double quotes etc. to get no improvement.

Pl help me how can i remove the lines containing >=5 hyphens (e.g., ----- )

Thanks
Prvn
Reply With Quote
Forum Sponsor
  #2  
Old 01-07-2008
Registered User
 

Join Date: Jun 2007
Posts: 80
Guess THis should work

sed -e 's/\-//g' filename

Regards,
Anand
Reply With Quote
  #3  
Old 01-07-2008
Registered User
 

Join Date: Jul 2007
Posts: 110
Your solution replaces all HYPHENs with NULL

My requirement is to remove the lines containing the string of 5 (or more) consecutive hyphens (e.g., ----- )

Thanks
Prvn
Reply With Quote
  #4  
Old 01-07-2008
Registered User
 

Join Date: Jun 2007
Posts: 80
Hope this should work

grep -v "\-" filename
Reply With Quote
  #5  
Old 01-07-2008
Registered User
 

Join Date: Jul 2007
Posts: 110
Thanks Aajan,

grep -v "\-----" filename WORKED
Reply With Quote
  #6  
Old 01-08-2008
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 290
grep -v -- - <filename> will also work; the double hypen prevents the next - from being interpreted as an option, but uses it as an arg
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:01 AM.


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

Content Relevant URLs by vBSEO 3.2.0