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
Scott
2
Why would you do that?
The shell interprets \ as a continuation character, not a newline. The newline that follows \ is removed.
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
Scott
4
echo $(echo $PGM_LIST | awk -v RS=" " '!/-/')
thanks! this is all I needed. Thanks for your help!
echo $PGM_LIST|sed 's/-[^ ]* //g'