【问题标题】:Search a text in a file in ubuntu and then print upto n no of lines thereafter在 ubuntu 中搜索文件中的文本,然后打印最多 n 行
【发布时间】:2012-04-28 18:47:55
【问题描述】:

我在服务器上有一个日志文件,我想检查它的日志,但它非常大。我怀疑行后有一些错误

at com.pckname.Classname.methodname(Classname.java:296)

我想从 ubuntu 的命令行编写一个 serach 命令,在找到上面写的文本的行号后,它会得到 n 行。

有人有什么想法吗?

我试过 'grep "search-string" ' 但这显然不能解决目的。通过上面的命令,我知道出了点问题,但是如果我在文件中得到最多几行的输出,我就会确切地知道问题出在哪里。

干杯

【问题讨论】:

    标签: linux ubuntu command-line


    【解决方案1】:
    grep 'your_search_string' --after-context=N your_log_file
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-21
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-06
      • 1970-01-01
      相关资源
      最近更新 更多