awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi,

I have line in input file as below:

3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL

My expected output for line in the file must be :

"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"

Can someone help me in this?

Where is "1-Radon1-cMOC_deg" and "LDIndex" coming from? They are not in the input file.

If 1-Radon1-cMOC_deg,LDIndex are constant then use

echo '3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL' | awk -F";" '{print "\"1-Radon1-cMOC_deg\"|\"LDIndex\"|\""$1OFS$2"\""OFS"LAST"OFS"\""$3"\""}' OFS="|"

1-Radon1-cMOC_deg,LDIndex,LAST are the fixed values which needs to be added to each line in the file.

 awk 'BEGIN{FS=";"; D="|"; Fix="\"1-Radon1-cMOC_deg\"|\"LDIndex\""} { s=""; for(i=1;i<=NF;i++) { s= i==NF? s D "LAST" : s; s=s D "\""$i"\""; } print Fix s }'

try this

Thanks Pravin and sk1428 for your solution.

@Pravin.How can I use your script to execute the command for thousand of such lines in a file?

Like this, add file at last.

awk -F";" '{print "\"1-Radon1-cMOC_deg\"|\"LDIndex\"|\""$1OFS$2"\""OFS"LAST"OFS"\""$3"\""}' OFS="|" INPUTFILE

Thanks Pravin