我需要创建一个 bash 文件来搜索日志文件中包含的所有行
Aug 9 16:11:46 igs kernel: [ATTS] Caution: IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=1.1.1.1 DST=192.168.0.100 LEN=33 TOS=0x00 PREC=0x00 TTL=121 ID=9690 DF PROTO=TCP SPT=601 DPT=12500 LEN=13
Aug 9 16:11:46 igs kernel: [ATTS] Caution: IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=2.2.2.2 DST=192.168.0.100 LEN=33 TOS=0x00 PREC=0x00 TTL=121 ID=9689 DF PROTO=TCP SPT=602 DPT=12502 LEN=13
Aug 9 16:11:46 igs kernel: [ATTS] Caution: IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=3.3.3.3 DST=192.168.0.100 LEN=33 TOS=0x00 PREC=0x00 TTL=121 ID=9691 DF PROTO=TCP SPT=600 DPT=12503 LEN=13
Aug 9 16:11:46 igs kernel: [ATTS] Caution: IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=1.1.1.1 DST=192.168.0.100 LEN=33 TOS=0x00 PREC=0x00 TTL=121 ID=9691 DF PROTO=TCP SPT=600 DPT=12503 LEN=13
然后提取“SRC=”中的IP并将IP保存到名称为“ip.list”的外部文件中,但不要重复相同的IP
ip.list 的示例输出
1.1.1.1
2.2.2.2
3.3.3.3