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.

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

Join Date: Nov 2008
Posts: 2
SED Help

Hi,

I have taken over maintaining some sed scripts and need a bit of help.

I have a file that launches a few sed commands like:

...
sed -f $SCRIPT_PATH/keep_jsp $LOGPATH/report > $REPORT_PATH/jsp1
sed -f $SCRIPT_PATH/keep_htm $LOGPATH/report > $REPORT_PATH/htm1
...

and the 'keep' file is as follows:

...
/ *\.pdf */!d
...

Basically this example keeps only the lines that have .pdf in them.
What I want to do is keep both .pdf and .kml

How can I modify just the one line in the 'keep' file to not delete pdf and kml lines? I don't want to mess with the whole structure of the scripts and change the sed line (the first file) to inclide -e's and stuff like that.

any help would be greatly appreciated.

Rob
  #2 (permalink)  
Old 11-13-2008
yahyaaa's Avatar
yahyaaa yahyaaa is offline
Registered User
  
 

Join Date: May 2008
Location: Jordan
Posts: 89
Not tested, but at least give it a try
/ *\.pdf */p
/ *\.kml */p

try to use grep if you like...
  #3 (permalink)  
Old 11-18-2008
rappleby rappleby is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 2
No, that didn't work.

Any other ideas? I need to do this in on line and not change any of the other functionality.

If I do the following:

------------------
/ *\.pdf */!d
/ *\.kml */!d
------------------

all I get is the lines that have .kml in them.

I want to basically have both lines applying but need them in one line (if you get what i mean)

thanks,
Rob
  #4 (permalink)  
Old 11-18-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Try this:
Code:
sed '/\.[pdf|klm]/!d' file
  #5 (permalink)  
Old 11-18-2008
joquendo joquendo is offline
Registered User
  
 

Join Date: Nov 2008
Location: New England
Posts: 5
sed '/\.pdf/!d; /\.klm/!d;\' file will work across the board (sun, linux, bsd)
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 09:02 PM.


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