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
remove lines in text starting with . (period) Movomito UNIX for Dummies Questions & Answers 11 04-24-2008 07:19 AM
How to delete first 5 lines and last five lines in all text files ragavendran31 Shell Programming and Scripting 10 02-21-2008 04:58 AM
How to delete initial N bytes from the starting of the file using sed? jockey007 Shell Programming and Scripting 3 11-19-2007 05:26 PM
How to delete N bytes from the starting of the file from a C function??? jockey007 High Level Programming 2 11-15-2007 07:25 PM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 04:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-13-2007
Registered User
 

Join Date: Oct 2006
Posts: 19
Post Delete lines starting with XX or YY or ZZ or ....

Hi There!

My final task for today is to delete lines starting with certain numbers

for e.g., my text block is
Quote:
P1
10,9:12/123456789
10,10:1
11,10:60
15,9:5/12345
15,10:1
15,14:1001
17,9:12/123456789
17,10:1
21,1:1
22,2:2
and i want to delete all lines starting with 11 or 17 or 21

I know i can use multiple sed commands like

sed '/^11,/d' <filename>
sed '/^17,/d' <filename>
sed '/^21,/d' <filename>


but is there any way of doing this in one sed command?

for e.g. sed '/^[11|17|21]/d' <filename>

Thanks again!
Reply With Quote
Forum Sponsor
  #2  
Old 11-13-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Code:
sed '/^1[17],/d;/^21,/d' filename
Reply With Quote
  #3  
Old 11-13-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,933
Or with grep:

Code:
egrep -v '^(1[17]|21),' filename
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:04 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