开发者

create an xml file using a shell script

I have a table with two columns

column_1 column_1
12345     12345
73255     73255
71377     71377 

Now i want to开发者_运维百科 create an xml like

<header>
<value>12345</value>
<value>73255</value>
<value>71377</value>
<footer>

basically i need to use a select query and put any one of the fields into the values of xml.

could you please suggest how could this be done in an easiest way? much appreciate your help.


imagine you have selected from the database and stored those columns in a file called "file"

#!/bin/bash
awk 'BEGIN{ print "<header>"}
NR>1{  print "<value>"$1"</value>" }
END{ print "<footer>"}' file

on the command line

# ./shell.sh
<header>
<value>12345</value>
<value>73255</value>
<value>71377</value>
<footer>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜