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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
can anyone help with shell script command about searching word with grep command? aintour Shell Programming and Scripting 2 10-14-2009 05:51 PM
problem with output of find command being input to basename command... new_learner UNIX for Dummies Questions & Answers 2 12-14-2008 02:56 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 01:29 PM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 07:54 AM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 09:12 PM

Reply
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-02-2009
tranz435 tranz435 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
Question help with sed command

Hi,

I am new to Unix scripting. I have a list as shown below. Now, I want to list only those words that doesnt start with "-".

PGM_LIST=" \
cls/dw_realease1 \
cls/dw_realease2 \
-cls/dw_realease3 \
cls/dw_realease4 \
-cls/dw_realease5 \
cls/dw_realease6 \
"

I tried this:
echo $PGM_LIST | sed '/-/d'

but its not giving correct results. Please help! I am using ksh
  #2 (permalink)  
Old 11-02-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,135
Why would you do that?

The shell interprets \ as a continuation character, not a newline. The newline that follows \ is removed.
  #3 (permalink)  
Old 11-02-2009
tranz435 tranz435 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
Yes, you are right, but I need to list all the words which doesnt start with "-"

So I want to see the output as:

cls/dw_realease1 cls/dw_realease2 cls/dw_realease4 cls/dw_realease6

basically omitting cls/dw_realease3 and cls/dw_realease5
  #4 (permalink)  
Old 11-02-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,135

Code:
echo $(echo $PGM_LIST | awk -v RS=" " '!/-/')

  #5 (permalink)  
Old 11-02-2009
tranz435 tranz435 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
thanks! this is all I needed. Thanks for your help!
  #6 (permalink)  
Old 11-02-2009
svenkatareddy svenkatareddy is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 22
grep -v '^-'
  #7 (permalink)  
Old 11-02-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 761

Code:
echo $PGM_LIST|sed 's/-[^ ]* //g'

Reply

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:35 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