码迷,mamicode.com
首页 > 数据库 > 详细

避免shell脚本SQL语句中 *输出时转义

时间:2017-03-07 23:28:51      阅读:470      评论:0      收藏:0      [点我收藏+]

标签:避免*转义

脚本test.sh内容如下,在 /home/myname/下执行该脚本,

家目录下有文件a.txt,test.log,test.sh

#!/bin/bash

sql="select * from emp;"

echo $sql

echo $sql > test.log

执行后结果:

select test.sh a.txt test.log from emp;

如何能让sql中的*不转义?

                                                                                                   

修改为如下:

#!/bin/bash
sql="select * from emp;"

echo "$sql"

echo "$sql" > test.log

再次执行,结果如下

select * from emp;


本文出自 “努力奔向前方” 博客,请务必保留此出处http://liucb.blog.51cto.com/3230681/1903960

避免shell脚本SQL语句中 *输出时转义

标签:避免*转义

原文地址:http://liucb.blog.51cto.com/3230681/1903960

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!