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

SED help

Status
Not open for further replies.

Milleniumlegend

IS-IT--Management
Dec 16, 2003
135
I am trying to substitue 4 lines with replaces.

define CA_ID=FRPSADSK122
define ISS_ID=9
define RUN_NBR_FROM=9
define RUN_NBR_TO=9

What I want to do is change the CA_ID value and the other values within them with a replacement value.

I have these values entered within a file and would like to change the values through sed and output them to a different file with the new values for these.

Could some one help me out with a sed command.

I was trying s/"define CA_ID=*$"/"define CA_ID=$ARG1"/ as we want to change them only once on line 4 and the others on the other lines.

Could someone help me to fix these.

Thanks
 
wich language is: define CA_ID=FRPSADSK122 ?

sed -e "s/\(CA_ID=\).*/\1$1/g
 
Something like this ?
sed "
/CA_ID/s!=.*!=$ARG1!
/ISS_ID/s!=.*!$ARG2!
/RUN_NBR_FROM/s!=.*!$ARG3!
/RUN_NBR_TO/s!=.*!$ARG4!
" /path/to/input >output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top