我有一个日志文件,一旦我找到This has happened due to.,我就试图存储所有的行,然后开始新的行。
所以基本上日志看起来是这样的
Bla bla bla bla....This has happened due to.
ABC
DEF
GHI
JKL你能帮我匹配一下帕特恩一旦我找到这行“这已经发生由于。”
发布于 2013-05-02 18:03:26
while (<>) {
next unless /This has happened due to/;
while (<>) {
# Process lines
}
last;
}发布于 2013-05-02 18:14:00
#!/usr/bin/env perl
while (<>) {
last if /This has happened due to/;
}
while (<>) {
print; # do smth with the line
}将脚本保存到文件并使其可执行。然后像./script.pl logfile一样运行
https://stackoverflow.com/questions/16335159
复制相似问题