看板 Perl 關於我們 聯絡資訊
請教一下,如果我有以下的文字檔: -A inside-outside -p tcp -m tcp -s 192.168.1.68 --dport 25 -j DROP -A inside-outside -m mac -s 192.168.1.2 --mac-source 00:0c:76:f5:7e:95 -j ACCEPT -A inside-outside -m mac -s 192.168.1.3 --mac-source 00:0e:2e:56:fb:f9 -j ACCEPT -A inside-outside -s 192.168.1.48 -j ACCEPT 我想抓出開頭有-A inside-outside -s的那一行文字,但是我若寫成: ……前面省略……… while (<IN>){ if (/-A inside-outside -s/){ print $_; } } 的話,會抓到: -A inside-outside -p tcp -m tcp -s 192.168.1.68 --dport 25 -j DROP -A inside-outside -s 192.168.1.48 -j ACCEPT 這二行,但是我只想要第二行,第一行不是我要的結果, 不知各位是否知道要如何改進? 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.77.218
iFEELing: ' ' 12/27 17:34
andytzeng:我拿你的 code 直接跑就真的只有哪一行而已呀 12/27 23:45