崬城衞 发表于 2018-8-27 06:33:27

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

  脚本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;

页: [1]
查看完整版本: 避免shell脚本SQL语句中 *输出时转义