简单看题grep --help
问题:想匹配 ttt.sql中 词语为 “8376” 的内容
一般回答:
grep -in "8376" ttt.sql
可是这样是想要的嘛?实际过滤出的数据,都不是想要的。只想要8376 这样的单词!!!
25444447:# at 88376417 25444448:#190510 16:11:53 server id 1003006 end_log_pos 88376535 CRC32 0x85c4d815 Table_map: `service`.`sys_customers` mapped to number 1926 25444449:# at 88376535 25444450:#190510 16:11:53 server id 1003006 end_log_pos 88376718 CRC32 0x1391a8e3 Write_rows: table id 1926 flags: STMT_END_F 25444483:# at 88376718 25444484:#190510 16:11:53 server id 1003006 end_log_pos 88376749 CRC32 0x1babef9c Xid = 109754020 25444486:# at 88376749 25444487:#190510 16:11:56 server id 1003006 end_log_pos 88376814 CRC32 0xee785ac2 GTID last_committed=62715 sequence_number=62716 rbr_only=yes 25444490:# at 88376814 25444491:#190510 16:11:53 server id 1003006 end_log_pos 88376885 CRC32 0x97334cd1 Query thread_id=3764778 exec_time=0 error_code=0 25444495:# at 88376885 25444642:#190510 16:11:56 server id 1003006 end_log_pos 88378376 CRC32 0xffc55e01 Write_rows: table id 1848 flags: STMT_END_F 25444675:# at 88378376 25453684:#190510 16:13:07 server id 1003006 end_log_pos 88458376 CRC32 0x29debe49 Write_rows: table id 1768 flags: STMT_END_F
正确姿势:\b 匹配
[[email protected] tmp]# grep -in "\b8376\b" ttt.sql 1271002:#190507 23:38:44 server id 1003006 end_log_pos 11187631 CRC32 0xb533e3c8 GTID last_committed=8375 sequence_number=8376 rbr_only=yes 1271230:#190507 23:38:46 server id 1003006 end_log_pos 11189622 CRC32 0xeca6fdf4 GTID last_committed=8376 sequence_number=8377 rbr_only=yes 9395311:### @27=8376.00 /* DECIMAL(11,2) meta=2818 nullable=0 is_null=0 */ 9395347:### @27=8376.00 /* DECIMAL(11,2) meta=2818 nullable=0 is_null=0 */ 9395383:### @27=8376.00 /* DECIMAL(11,2) meta=2818 nullable=0 is_null=0 */ 16269738:#190509 15:37:45 server id 1003006 end_log_pos 8048856 CRC32 0xb2970055 GTID last_committed=8375 sequence_number=8376 rbr_only=yes 16269966:#190509 15:37:47 server id 1003006 end_log_pos 8050829 CRC32 0x99e4a78c GTID last_committed=8376 sequence_number=8377 rbr_only=yes
原文地址:https://www.cnblogs.com/monkeybron/p/10846430.html
时间: 2024-10-21 17:48:29