LEN

Awk 字符串截取实例
大半夜的需要找bug, get awk 新技能 记录下日志文件[2018/08/09 23:37:20] _333...
扫描右侧二维码阅读全文
10
2018/08

Awk 字符串截取实例

大半夜的需要找bug, get awk 新技能 记录下
日志文件

[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('83', 'xsx', '0', '-5305.0156', '1533829040352', '1533829040352')
[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('77', 'xsx', '5299.7105844000000000', '0', '1533829040366', '1533829040366')
[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('83', 'xsx', '0', '-2910.9732', '1533829040385', '1533829040385')
[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('74', 'xsx', '2908.0622268000000000', '0', '1533829040393', '1533829040393')
[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('83', 'xsx', '0', '-4074.4491', '1533829040404', '1533829040404')
[2018/08/09 23:37:20] _3339867009106186240_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('99', 'xsx', '4070.3746509000000000', '0', '1533829040433', '1533829040433')
[2018/08/09 23:37:29] _3339868244043501568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('87', 'xsx', '9262.3082202000000000', '0', '1533829049567', '1533829049567')
[2018/08/09 23:37:38] _3339869416838008832_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('72', 'xsx', '10079.4670434000000000', '0', '1533829058302', '1533829058302')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('28', 'xsx', '0', '-10849.4314', '1533829067049', '1533829067049')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '10838.5819686000000000', '0', '1533829067058', '1533829067058')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('30', 'xsx', '0', '-6482.6165', '1533829067070', '1533829067070')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '6476.1338835000000000', '0', '1533829067080', '1533829067080')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('15', 'xsx', '0', '-1758.1030', '1533829067106', '1533829067106')
[2018/08/09 23:37:47] _3339870592853741568_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '1756.3448970000000000', '0', '1533829067155', '1533829067155')
[2018/08/09 23:37:47] _3339870660902129664_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('15', 'xsx', '0', '-5144.9479', '1533829067554', '1533829067554')
[2018/08/09 23:37:47] _3339870660902129664_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('17', 'xsx', '5139.8029521000000000', '0', '1533829067566', '1533829067566')
[2018/08/09 23:37:47] _3339870660902129664_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('41', 'xsx', '0', '-9359.1961', '1533829067577', '1533829067577')
[2018/08/09 23:37:47] _3339870660902129664_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('17', 'xsx', '9349.8369039000000000', '0', '1533829067583', '1533829067583')
[2018/08/09 23:37:53] _3339871450370805760_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('67', 'xsx', '4594.9123881000000000', '0', '1533829073666', '1533829073666')
[2018/08/09 23:37:54] _3339871567140229120_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('94', 'xsx', '0', '-6251.7375', '1533829074305', '1533829074305')
[2018/08/09 23:37:54] _3339871567140229120_ @ INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('99', 'xsx', '6245.4857625000000000', '0', '1533829074312', '1533829074312')

Awk

 cat Sql-40-20180809.log |grep 67 |grep xsx |grep table |grep -i insert |awk '{print substr($0, 46)}'

处理后

 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('87', 'xsx', '9262.3082202000000000', '0', '1533829049567', '1533829049567')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('72', 'xsx', '10079.4670434000000000', '0', '1533829058302', '1533829058302')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('28', 'xsx', '0', '-10849.4314', '1533829067049', '1533829067049')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '10838.5819686000000000', '0', '1533829067058', '1533829067058')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('30', 'xsx', '0', '-6482.6165', '1533829067070', '1533829067070')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '6476.1338835000000000', '0', '1533829067080', '1533829067080')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('15', 'xsx', '0', '-1758.1030', '1533829067106', '1533829067106')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('22', 'xsx', '1756.3448970000000000', '0', '1533829067155', '1533829067155')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('15', 'xsx', '0', '-5144.9479', '1533829067554', '1533829067554')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('17', 'xsx', '5139.8029521000000000', '0', '1533829067566', '1533829067566')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('41', 'xsx', '0', '-9359.1961', '1533829067577', '1533829067577')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('17', 'xsx', '9349.8369039000000000', '0', '1533829067583', '1533829067583')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('67', 'xsx', '4594.9123881000000000', '0', '1533829073666', '1533829073666')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('94', 'xsx', '0', '-6251.7375', '1533829074305', '1533829074305')
 INSERT  INTO table (`xxt`, `item`, `xxx`, `lxxx`, `created`, `updated`)  VALUES ('99', 'xsx', '6245.4857625000000000', '0', '1533829074312', '1533829074312')
Last modification:August 10th, 2018 at 12:27 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment