提取日志文件的最后一部分

我如何提取给定行之后的文件的所有内容? 该行可以通过确切的内容或正则expression式进行匹配。

 awk'BEGIN {found = 0;  } / RE GOES HERE / {found = 1;  }find{print;  }'$ filename

避免多个文件遍历,所以应该(可能)对大文件执行更好的匹配是文件的结尾。

tail -n +`egrep -n "pattern" "file_to_search.txt" | cut -d ":" -f 2 | tail -n 1` "file_to_tail.txt" 

这个简单的awk程序应该能够完成这个工作:

 awk '/pattern/,""' filename 

并且:

 sed -n '/pattern/,$ p' filename