awk可以打印没有图案的行吗? [英] Can awk print lines that do not have a pattern?

查看:63
本文介绍了awk可以打印没有图案的行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

awk可以打印所有与其中一种模式不匹配的行吗?

Can awk print all lines that did not match one of the patterns?

换句话说,我想变换一些线条,但其余部分保持不变.因此,如果/pattern/匹配,我将提供一个自定义块来打印行.我只需要提供一个默认匹配器(如else)即可打印其他行.

In other words, I want to transform some lines but leave the rest unchanged. So, if a /pattern/ matched I would provide a custom block to print the line. I just need to provide a default matcher (like an else) to print the other lines.

推荐答案

是的,只需使用任何非零数字,awk就会执行其默认操作,即打印该行:

Yes, just use any non-zero number and awk will do its default thing which is to print the line:

awk '7' file

如果您希望将其作为"else",请在为特殊处理选择的任何行之后加上"next",这样就不会对它们执行同样的操作.

If you want it as an "else", put "next" after whatever lines you select for special processing so this one isn't executed for them too.

awk '/pattern/{special processing; next} 7' file

这篇关于awk可以打印没有图案的行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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