-3

Each record coming with column names. I have to replace them in each record as shown below:

TIME=20181219110000275|CHAN=FMBKHJBAAAADPCFNAAAAAABA|EVNT=SWIgrld|API=SWIrecGrammarActivate|TYPE=uri/2.0|URI=http://media-elr/en-us/grammar/PRVS05/PRVS_param_gram.grxml?SWI.appsessionid=00053050771545238465&SWI.appstepid=1|WGHT=1|PROPS=inet.timeoutDownload=5000;inet.timeoutIO=5000;inet.timeoutOpen=5000;inet.urlBase=http://vxml3-elr:7000/CVP/;swirec_language=en-US|FETCHES=0|MEMHITS=1|MEMMISS=0|DISKHITS=0|DISKMISS=0|LDCPU=0|LDTIME=1|GCCPU=0|GCTIME=0|IFCPU=0|IFTIME=0|IFBYTES=0|COMPILES=0|RC=0|UCPU=186093|SCPU=30828

Output should look like:

20181219110000275|FMBKHJBAAAADPCFNAAAAAABA|SWIgrld|SWIrecGrammarActivate|uri/2.0|http://media-elr/en-us/grammar/PRVS05/PRVS_param_gram.grxml?SWI.appsessionid=00053050771545238465&SWI.appstepid=1|1|inet.timeoutDownload=5000;inet.timeoutIO=5000;inet.timeoutOpen=5000;inet.urlBase=http://vxml3-elr:7000/CVP/;swirec_language=en-US|0|1|0|0|0|0|1|0|0|0|0|0|0|0|186093|30828
  • 1
    Welcome to U&L, what have you tried so far? – Archemar Dec 28 '18 at 17:15
0
  string='abc=something|efgh=anotherThing|klmnop=yet_another_thing'
  string='|'$string    #to prepend with '|' and have a pattern
  result=$( echo "$string" | sed 's/|[a-zA-Z]*=/|/g' )
  result=${result:1}   # remove the leading '|' we added

  something|anotherThing|yet_another_thing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.