有时候就简单的 select-insert不想编程实现。使用shell脚本完成
1. 装mysql
2.shell 版本,会影响while遍历方式3.0之后使用 ·done <<< ·。3.0之前使用done< <
#/bin/bash
time=$1
host="10.sss.sss.ss"
port="3306"
userName="xx"
passwd="xxx"
dbname="mydb"
dbset="--default-character-set=utf8 -A"
jobinfo_sjs=jobinfo_sjs
cmd="mysql -h${host} -P${port} -u${userName} -p${passwd} ${dbname}"
#echo "select * from ${jobinfo_sjs} limit 1;" | ${cmd}
sql="SELECT DISTINCT projectId FROM ${jobinfo_sjs} WHERE date='${time}' AND ownner='ultraman'"
#declare projecIdtList=`${cmd} -e "${sql}"` #执行mysql的查询
#for list in $projecIdtList
#do
# echo " the item is $list"
#done
while read row
do
echo "..${row}.."
done <<< `echo "SELECT DISTINCT projectId FROM ${jobinfo_sjs} WHERE date='${time}' AND ownner='ultraman'" | ${cmd}`
shell3.0之前的参考
https://blog.csdn.net/u011630575/article/details/52152676
https://www.cnblogs.com/hanxiangduo/archive/2012/01/15/shell_read_data_from_mysql.html