Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk or sed 1

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
I'm tidying up some old code (not mine!) and I've come across
Code:
#Remove tabs (\t or \011) and 'squeeze' out line feeds (\n or \012)
cat $tmp/pbecsu.tmp.$$|tr "\011" " "|tr -s "\012"|grep PBEC|grep -v typopn >> $tmp/pbec.tmp.$$

rm -f $tmp/pbecsu.tmp.$$

#Put quotes around each field and remove spaces, except for first 2 records
sed -e '2,$ s/^/"/; 2,$ s/;/","/g; 2,$ s/$/"/; 3,$ s/ //g' $tmp/pbec.tmp.$$ > $FNAME
Ignoring the bit about the first two records (I'm sorting that out elsewhere) and the way it only deletes spaces from the third line on I'm looking to combine all this into one awk or sed statement. If it's awk then
Code:
awk '/PBEC/ && ! /typopn/ { .... }' input > output
but I can't work out how to put a sed type statement in the braces. On the other hand, if I use sed then I can't work out how to do the grep like statements. I've been buried in the lemur book for hours and I'm getting nowhere. Any pointers please.

Ceci n'est pas une signature
Columb Healy
 
Have a look at the sub and gsub functions.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PH - if you knew how much money (in terms of my time) you have saved my company in this and many other posts you would be sending me a bill!

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top