该脚本是先删除已经存在的文件,然后后台执行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 <<eof
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
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
-
嵌入式学习经历帖
随着科技的进步,全凭机械结构完成各种运动的时代已经渐行渐远,不过我仍然对于之前创造的各种运动机构着迷。现在技术的...
[阅读全文]
-
-
-
网友评论