+ -
当前位置:首页 → 问答吧 → shell脚本中设置mysql记录分隔符为回车

shell脚本中设置mysql记录分隔符为回车

时间:2011-12-04

来源:互联网

脚本如下。想用shell脚本读取mysql中数据,写入在ttt.txt中,每条记录之间用回车间隔。
C/C++ code

echo $(mysql  -N -r -B  -h192.168.1.1 -uname -ppassword -P3316 << EOF
select concat(crm_cust_id,'\n') from integration.UM_MAPPING_CUST;
  exit
  EOF
 ) > ttt.txt


但是运行结束之后,ttt.txt中还是以空格间隔。
应该怎么做呢?

作者: haoyyy   发布时间: 2011-12-04

默认出来的就是每行一个回车的 你直接试试select concat(crm_cust_id,'\n') from


或者直接不用echo
mysql -N -s -h192.168.1.1 -uname -ppassword -P3316 -e "
select concat(crm_cust_id,'\n') from integration.UM_MAPPING_CUST;"> ttt.txt

作者: rucypli   发布时间: 2011-12-04

这样试试 "$()"

作者: qq120848369   发布时间: 2011-12-04