开发者

create an xml file using a shell script

开发者 https://www.devze.com 2022-12-09 17:39 出处:网络
I have a table with two columns column_1 column_1 1234512345 7325573255 7137771377 Now i want to开发者_运维百科 create an xml like

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

精彩评论

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