创建使用shell脚本的XML文件 [英] create an xml file using a shell script

查看:233
本文介绍了创建使用shell脚本的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两列的表

column_1 column_1
12345     12345
73255     73255
71377     71377

现在我想创建像

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

基本上,我需要使用一个选择查询,并把领域中的任何一个为XML的值。

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

您可以请建议怎么会这样以最简单的方式来完成?
多AP preciate你的帮助。

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

在命令行上

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

这篇关于创建使用shell脚本的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆