在文件中搜索多个模式并在模式匹配时删除行 [英] search multiple pattern in file and delete line if pattern matches

查看:16
本文介绍了在文件中搜索多个模式并在模式匹配时删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,一个文件包含内容:

For ex, a file contain contents:

10.45.56.84 raj
10.49.31.81 mum
10.49.31.86 mum
10.81.51.92 guj
10.45.56.116 raj
10.45.56.84 raj

我想在上面的文件中搜索10.45.56.8410.81.51.92,如果模式匹配就删除一行.

I want to search 10.45.56.84 and 10.81.51.92 in the above file and delete line if pattern matches.

我也想在单个命令中执行此操作.

Also i want to do this in single command.

推荐答案

另一种解决方案:

 awk '!/10.45.56.84|10.81.51.92/' file

这篇关于在文件中搜索多个模式并在模式匹配时删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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