打赏

星辰大海ゞ

That which does not kill us makes us stronger!

导航

while read line

# grep "请求报文:" application-20170822-*.log >> applog

# cat applog|cut -d ":" -f2 >> mylog

# cat mylog | while read line ; do mysql -h192.168.55.254 -uceshi -pCeshi123 -e "use mydb;insert into pengcheng (log) values ('$line');" ; done

 

发现当一行的内容过多时,使用  for aa in `cat mylog` ; do ...时,不能读取整行的内容,但是使用 while read line 语句可以实现。

另外,当在linux系统中使用mysql客户端命令时,也要记得修改mysql客户端的字符编码,即 my.cnf 文件添加:

[client]
default-character-set = utf8

 

posted on 2017-08-22 15:57  星辰大海ゞ  阅读(373)  评论(0编辑  收藏  举报