Operating System - HP-UX
1834510 Members
3048 Online
110068 Solutions
New Discussion

So they tell me to use awk..

 
SOLVED
Go to solution
Carlo Henrico_1
Regular Advisor

So they tell me to use awk..

OK All I need to do is in a text file replace all occurences of the string "CHANNEL" with "STOP CHANNEL" and all the occurences of ")" with ") MODE(QUIESCE)"

aa.awk
CHANNEL=STOP CHANNEL
)=) MODE(QUIESCE)

a.txt
CHANNEL(A.B.C)

should become

b.txt
STOP CHANNEL(A.B.C) MODE(QUIESCE)

using
awk -f aa.awk a.txt > b.txt

This is not working. Can someone help please?

Thanks

Carlo
Live fast, die young - enjoy a good looking corpse!
2 REPLIES 2
Santosh Nair_1
Honored Contributor
Solution

Re: So they tell me to use awk..

How about using sed instead:

sed -e "s/CHANNEL/STOP CHANNEL/g" -e "s/)/MODE(QUIESCE)/g" a.txt

-Santosh
Life is what's happening while you're busy making other plans
Andreas Voss
Honored Contributor

Re: So they tell me to use awk..

Hi

with awk you could do:

awk '{sub("CHANNEL", "STOP CHANNEL");sub(")", ") MODE(QUIESCE)");print $0}' a.txt

Regards