awk 语句

awk  -F ',' '{print "update tblClassInfo set class_type = 1, ext = \047{\"class_name\":\""$3"\", \"teacher_name\":\""$4"\"}\047 where class_code = "$1";"}' 1.txt
1,1,哈哈哈,呃呃呃
2,2,哈哈哈,呃呃呃呃
3,3,dsad,cxcxzc
4,4,fdsafdsa,fdsafsafds

 下面这条sql语句在输出的时候总是输出错误,后来发现是$3后面有换行符导致的,这一点以后要注意,不要粗心了。

awk  -F ',' '{print "insert into tblClassUserConfs(cate, uid, create_time, update_time, ext) value (1, "$3", 1595246294, 1595246294, \047{\"email\":\""$1"\"}\047) on duplicate key update ext = \047{\"email\":\""$1"\"}\047;"}' 1.txt

 

posted @ 2020-07-15 17:21  泥土里的绽放  阅读(170)  评论(0编辑  收藏  举报