The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10: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 07: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 08: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 10:25 PM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 07:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2007
orno orno is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 21
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!
  #2 (permalink)  
Old 11-13-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
sed '/^1[17],/d;/^21,/d' filename
  #3 (permalink)  
Old 11-13-2007
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

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

Code:
egrep -v '^(1[17]|21),' filename
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0