[問題] 要怎麼抓取這些字串?
請教一下,如果我有以下的文字檔:
-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
→
12/27 17:34, , 1F
12/27 17:34, 1F
→
12/27 23:45, , 2F
12/27 23:45, 2F
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章