Search and replace text

HI

I have property files having content

QA_server_name=10.232.54.7
QA_port_number=18000
DEV_server_name=10.235.60.73
DEV_port_number=18000

and a .jason file having content like this

{
       "server":"localhost"
       "port":"17000"
        ------
}

I will get the parameter from the use as the QA or DEV based on that ,
i need to replace the values in .jason file,for eg if the user wants to replace dev parameters ,the scripts shouls read the values for DEV in property file and replace it in the .jason file

so the output shourld be

{
      "server":"10.235.60.73"
       "port":"18000"
        ------
}

Regards
Mohammed Tausif

Try this:

awk '
  NR==FNR{ if(/^QA|DEV/){store[$2]=gensub(/.*=/,"","g",$3)}; next}
  ($2 in store) {$4=store[$2]} 
  1' FS="_" property.txt FS='"' OFS='"' .jason

that FS and OFS at the and are single double single quote

Next time, if you post a question of this is sort into the "scripting" forum, you'll get a response faster. :wink: