我有一个日志文件,一旦找到,我就会尝试存储所有行This has happened due to.
,然后开始新行。
所以基本上日志看起来像这样
Bla bla bla bla....This has happened due to.
ABC
DEF
GHI
JKL
一旦我找到“这已经发生由于”这一行,你能帮我匹配一下模式吗?
我有一个日志文件,一旦找到,我就会尝试存储所有行This has happened due to.
,然后开始新行。
所以基本上日志看起来像这样
Bla bla bla bla....This has happened due to.
ABC
DEF
GHI
JKL
一旦我找到“这已经发生由于”这一行,你能帮我匹配一下模式吗?
while (<>) {
next unless /This has happened due to/;
while (<>) {
# Process lines
}
last;
}
#!/usr/bin/env perl
while (<>) {
last if /This has happened due to/;
}
while (<>) {
print; # do smth with the line
}
将脚本保存到文件并使其可执行。然后像这样运行./script.pl logfile