如何在grep中为新行提供模式? [英] How to give a pattern for new line in grep?

查看:10
本文介绍了如何在grep中为新行提供模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在grep中为新行提供模式?开头换行,结尾换行.不是正则表达式方式.类似 .

How to give a pattern for new line in grep? New line at beginning, new line at end. Not the regular expression way. Something like .

推荐答案

grep 模式与单个行匹配,因此模式无法匹配输入中的换行符.

grep patterns are matched against individual lines so there is no way for a pattern to match a newline found in the input.

但是你可以找到这样的空行:

However you can find empty lines like this:

grep '^$' file
grep '^[[:space:]]*$' file # include white spaces 

这篇关于如何在grep中为新行提供模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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