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

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

问题描述

grep -A1 'blah' logfile

多亏了这个命令,每一行都有 'blah' ,我得到了包含 'blah' 的行的输出以及日志文件中的下一行.这可能是一个简单的方法,但我找不到一种方法来省略具有 'blah' 和 only 在输出中显示下一行的行.

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.

推荐答案

你可以用awk试试:

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

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

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