- 论坛徽章:
- 0
|
本帖最后由 侧面bt 于 2010-07-07 12:00 编辑
现在要把错误日志文件里面的sql语句提出来,组合成正确的重装执行,日志文件的格式如下:
[time] 2010-07-05 10:45:54.765432
[tid] 6308
[file] ../src/DBOpr.cpp
[line] 38
[info] DB Error: Fail To Execute SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UpdatePeroid = 0 where id= 1164605496' at line 1
SQL: update table_29 set dname = 'sunsecond.com', IPNum = 1, IP = '114.80.162.3', UpdateTime = '2010-07-05 10:45:54' UpdatePeroid = 0 where id = 116460549
[time] 2010-07-05 10:45:57.229553
[tid] 6310
[file] ../src/DBOpr.cpp
[line] 38
[info] DB Error: Fail To Execute SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UpdatePeroid = 0 where id= 14204116719' at line 1
SQL: update table_21 set dname = '15aaa.com', IPNum = 3, IP = '173.244.202.183
n173.244.202.184
173.244.202.189'
UpdateTime = '2010-07-05 10:45:57' UpdatePeroid = 0 where id = 1420411671
现在的问题是对于ip个数是1个的倒还好处理,因为都在一行内,但对于IP有多个的,由于IP这个字段是换\n分隔的,所以在日志文件里变成了多行,还在要还原为一行,比如第一条记录要还原成:
update table_21 set dname = '15aaa.com', IPNum = 3, IP = '173.244.202.183\n173.244.202.184\n173.244.202.189' UpdateTime = '2010-07-05 10:45:57' UpdatePeroid = 0 where id = 142041167
请问黑哥该怎么处理啊,用什么好,awk还是sed还是其它方法,谢了,对了,日志记录非常大,大概有10万条以上。 |
|