当前位置: 动力学知识库 > 问答 > 编程问答 >

shell - i have to pick the value of a paramter specified in text file and put it into the parameter value in xml

问题描述:

I have a text file

Values.txt(contents mentioned below)

IMSI,MSISDN

678,7890

I have an xml with IMSI and MSISDN values specified like this

 <item>

<key>IMSI</key>

<value>404720000000004</value>

</item>

<item>

<key>MSISDN</key>

<value>917329390086</value>

</item>

I have to read the Values.txt and pick the IMSI and MSISDN values and put it into xml in the place of IMSI and MSISDN values.

网友答案:
awk -v FS=, '/[0-9]/{print "<key>IMSI</key>",$1,"<key>MSISDN</key>",$2}' input | \
    sed 's!\([^ ][^ ]*\) \([^ ]*\)!<item>\n\t\1\n\t<value>\2</value>\n</item>\n!g'
分享给朋友:
您可能感兴趣的文章:
随机阅读: