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!

Need help with awk

Status
Not open for further replies.

smaubleu

Programmer
Oct 4, 2007
1
FR
Hello,
I need to re-format a string using awk.

each occurence of P_1542_SET_N should become CAG(P_1542)=NORMAL. for exemple
P_1542_SET_N AND P_1642_SET_R
=>
CAG(P_1542)=NORMAL AND CAG(P_1642)=REVERSE

I tried something like :
gsub("P_[0-9][0-9][0-9][0-9]","CAG(P_[0-9][0-9][0-9][0-9])=NORMAL",MyString);
but I on ly get P_[0-9][0-9][0-9][0-9] in each occurence.

Does anyone has an idea ?
Many thancks
 
A sed way:
Code:
sed 's!\(P_[0-9][0-9][0-9][0-9]\)_SET!CAG(\1)=!g;s!=_N!=NORMAL!g;s!=_R!=REVERSE!g' input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top