您现在的位置是:网站首页> 编程资料编程资料
把mysql查询结果保存到文件的shell脚本_linux shell_
2023-05-26
404人已围观
简介 把mysql查询结果保存到文件的shell脚本_linux shell_
该脚本是先删除已经存在的文件,然后后台执行SQL语句将其执行结果以一定的格式写入文件
复制代码 代码如下:
#!/bin/bash
if [ -f "/var/lib/mysql/hell.txt" ]; then
rm -f /var/lib/mysql/hell.txt
echo "delete /var/lib/mysql/hell.txt" >> hell.txt
fi
mysql -uroot -plab <use home;
select YongHuID,XueYuanID into outfile './hell.txt' fields terminated by '|' lines terminated by '\r\n' from sns_home_user where YongHuID < 20;
EOF
if [ -f "/var/lib/mysql/hell.txt" ]; then
rm -f /var/lib/mysql/hell.txt
echo "delete /var/lib/mysql/hell.txt" >> hell.txt
fi
mysql -uroot -plab <
select YongHuID,XueYuanID into outfile './hell.txt' fields terminated by '|' lines terminated by '\r\n' from sns_home_user where YongHuID < 20;
EOF
相关内容
- shell获取命令行参数示例分享_linux shell_
- vtune自动安装脚本分享_linux shell_
- 获取站点的各类响应时间(dns解析时间,响应时间,传输时间)_linux shell_
- shell脚本转发80端口数据包给Node.js服务器_linux shell_
- centos中mysql备份数据库脚本分享_linux shell_
- shell中删除文件中重复行的方法_linux shell_
- shell替换文件中的文件路径脚本分享_linux shell_
- shell脚本操作oracle删除表空间、创建表空间、删除用户_linux shell_
- shell对比文件内容脚本分享_linux shell_
- shell使用mysqld_multi自动做多实例从库脚本_linux shell_
