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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vi question? 1

Status
Not open for further replies.

scorney

Technical User
Sep 15, 2003
115
CA
Hi, I have a file similar to that with 50 lines. I'd like to change eqstatfac0=o,eqstatfac1=o for AFACIDFAC0=1101,AFACIDFAC1=1102 this was for DFI=01 but i need to do this for all of them and incremente the 1101 to 1200, like I mention i have 50 lines and on each single line i have 2 things to change so 2 numbers. I'm sure it could be easy but I can't figure out.
It sure I could do a substitute for each lines but if a sort of a scripts could be done then it will make my life easier in the future. like s/eqstatfac0=o,eqstatfac1=o/AFACIDFAC0=1101,AFACIDFAC1=1102/p but if it can be done easier way.
Here are a portion of the lines:

FORM=20v4&CHG,SM=010,DLTU=05,DFI=01,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=02,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=03,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=04,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=05,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=06,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=07,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=08,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=09,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|

FORM=20v4&CHG,SM=010,DLTU=05,DFI=10,FACIND=3,eqstatfac0=O,eqstatfac1=O,chg!|010|


Thanks
msn.com@sly_corney
Email address is reversed to avoid the spam.
 
The awk way:
awk -F, '
BEGIN{id=1100}
{$6="AFACIDFAC0="++id;$7="AFACIDFAC1="++id;print}
' /path/to/inputfile >output

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
:g/eqstatfac0=o,eqstatfac1=o/s//AFACIDFAC0=1101,AFACIDFAC1=1102/p
should work for you.

which does globally :)g) on every line that has 'eqstatfac0=o,eqstatfac1=o' it substitutes for the current search buffer 's//' for 'AFACIDFAC0=1101,AFACIDFAC1=1102'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top