如何在匹配的后面显示下一行? [英] How to show only next line after the matched one?

查看:85
本文介绍了如何在匹配的后面显示下一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  grep -A1'blah'日志文件

感谢这个命令对于每一行有'blah'的行,我得到包含'blah'的行的输出以及日志文件中后面的下一行。这可能是一个简单的方法,但我无法找到一种方法来省略只有'blah'和 显示输出中下一行的行。

  awk'/ blah / {函数getline; print}'logfile 


grep -A1 'blah' logfile

Thanks to this command for every line that has 'blah' in it, I get the output of the line that contains 'blah' and the next line that follows in the logfile. It might be a simple one but I can't find a way to omit the line that has 'blah' and only show next line in the output.

解决方案

you can try with awk:

awk '/blah/{getline; print}' logfile

这篇关于如何在匹配的后面显示下一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆