linux grep 排除

grep is very useful tool used by a lot of tech guys. grep provides different functions to match given text. We have all ready mentioned these useful options of grep. In this tutorial we will look different ways to exclude in grep.

grep是许多技术人员使用的非常有用的工具。 grep提供了不同的功能来匹配给定的文本。 我们已经准备好提及grep的这些有用选项。 在本教程中,我们将寻找在grep中排除的不同方法。

Linux egrep Command Tutorial with Examples

带有示例Linux egrep命令教程

-v选项排除(Exclude with -v  Option)

The basic way to exclude given term line from given text is -v  option. This will look for given term and remove line which contains term. In this example we will remove lines contains IP address 192.168.1.1 by using -v option.

从给定文本中排除给定术语行的基本方法是-v选项。 这将查找给定的术语并删除包含术语的行。 在此示例中,我们将使用-v选项删除包含IP地址192.168.1.1的行。

$ grep -v "192.168.115.128" syslog.1

How To Exclude with Grep In Linux?
如何在Linux中排除Grep?

多个Grep的多重排除 (Multiple Exclude with Multiple Grep)

What if we need multiple excludes? We can use multiple grep too. We can pipe multiple grep end to end. We will exclude poftut  and com terms from file named syslog.1 with the following command.

如果我们需要多个排除对象怎么办? 我们也可以使用多个grep 。 我们可以通过管道将多个grep端到端。 我们将使用以下命令从名为syslog.1文件中排除poftutcom术语。

$ grep -v "poftut" syslog.1 | grep "com"

扩展正则表达式的多重排除 (Multiple Exclude with Extended Regex)

grep  command provides extended regex functionality. This is used to provide multiple regex pattern in a single shot. We can use this feature in order to exclude multiple terms. We will use -e  option and provide regex patterns. We will exclude dhclient  and com with the following command.

grep命令提供了扩展的正则表达式功能。 这用于在单个镜头中提供多个正则表达式模式。 我们可以使用此功能来排除多个术语。 我们将使用-e选项并提供正则表达式模式。 我们将使用以下命令排除dhclientcom

$ grep -v  -e "dhclient" -e "com" syslog.1

Multiple Exclude with Extended Regex
扩展正则表达式的多重排除

排除尾部命令输出(Exclude Tail Command Output)

tail command provides the ability to read log files by streaming. But if there is a lot of logs this may be hard to read. We can use grep  with tail  command to gather to filter unwanted lines. We will pipe the tail  command output to the grep  command. We will filter lines those provides anacron

tail命令提供了通过流读取日志文件的功能。 但是,如果有很多日志,可能很难阅读。 我们可以将greptail命令一起使用,以过滤掉不需要的行。 我们将通过tail命令输出到grep命令。 我们将过滤那些提供anacron线

$ tail -f syslog.1 | grep -v "anacron"

Exclude with Command Output
用命令输出排除
.u9c6cd678178f5d3ef13870f5a90f76e8 , .u9c6cd678178f5d3ef13870f5a90f76e8 .postImageUrl , .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text-area { min-height: 80px; position: relative; } .u9c6cd678178f5d3ef13870f5a90f76e8 , .u9c6cd678178f5d3ef13870f5a90f76e8:hover , .u9c6cd678178f5d3ef13870f5a90f76e8:visited , .u9c6cd678178f5d3ef13870f5a90f76e8:active { border:0!important; } .u9c6cd678178f5d3ef13870f5a90f76e8 .clearfix:after { content: ""; display: table; clear: both; } .u9c6cd678178f5d3ef13870f5a90f76e8 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u9c6cd678178f5d3ef13870f5a90f76e8:active , .u9c6cd678178f5d3ef13870f5a90f76e8:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text-area { width: 100%; position: relative; } .u9c6cd678178f5d3ef13870f5a90f76e8 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u9c6cd678178f5d3ef13870f5a90f76e8 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u9c6cd678178f5d3ef13870f5a90f76e8 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u9c6cd678178f5d3ef13870f5a90f76e8:hover .ctaButton { background-color: #E67E22!important; } .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u9c6cd678178f5d3ef13870f5a90f76e8 .u9c6cd678178f5d3ef13870f5a90f76e8-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u9c6cd678178f5d3ef13870f5a90f76e8:after { content: ""; display: block; clear: both; }

LEARN MORE  How To Use Regex (Regular Expression) with Grep?

.u9c6cd678178f5d3ef13870f5a90f76e8 , .u9c6cd678178f5d3ef13870f5a90f76e8 .postImageUrl , .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text-area { min-height: 80px; position: relative; } .u9c6cd678178f5d3ef13870f5a90f76e8 , .u9c6cd678178f5d3ef13870f5a90f76e8:hover , .u9c6cd678178f5d3ef13870f5a90f76e8:visited , .u9c6cd678178f5d3ef13870f5a90f76e8:active { border:0!important; } .u9c6cd678178f5d3ef13870f5a90f76e8 .clearfix:after { content: ""; display: table; clear: both; } .u9c6cd678178f5d3ef13870f5a90f76e8 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u9c6cd678178f5d3ef13870f5a90f76e8:active , .u9c6cd678178f5d3ef13870f5a90f76e8:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text-area { width: 100%; position: relative; } .u9c6cd678178f5d3ef13870f5a90f76e8 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u9c6cd678178f5d3ef13870f5a90f76e8 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u9c6cd678178f5d3ef13870f5a90f76e8 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u9c6cd678178f5d3ef13870f5a90f76e8:hover .ctaButton { background-color: #E67E22!important; } .u9c6cd678178f5d3ef13870f5a90f76e8 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u9c6cd678178f5d3ef13870f5a90f76e8 .u9c6cd678178f5d3ef13870f5a90f76e8-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u9c6cd678178f5d3ef13870f5a90f76e8:after { content: ""; display: block; clear: both; }

了解更多如何在Grep中使用正则表达式(正则表达式)?

翻译自: https://www.poftut.com/exclude-grep-linux/

linux grep 排除

linux grep 排除_如何在Linux中排除Grep?相关推荐

  1. linux查看图像大小_如何在Linux上调整一批图像的大小?

    linux查看图像大小 Resizing images on Linux with gThumb is easy. However, I have a batch of images inside a ...

  2. linux xargs命令_如何在Linux中使用xargs命令?

    linux xargs命令 The xargs command allows us to pass the output of one command as the input for another ...

  3. linux uniq命令_如何在Linux上使用uniq命令

    linux uniq命令 Fatmawati Achmad Zaenuri/ShutterstockFatmawati Achmad Zaenuri / Shutterstock The Linux ...

  4. linux rar加压_如何在linux下解压缩rar格式的文件压缩包

    ######################################################### #老男孩笔记系列-如何在linux下解压缩rar格式的文件压缩包 #date:201 ...

  5. bash中的grep函数_如何在Bash中编写函数

    bash中的grep函数 在编程时,实际上是在定义要由计算机执行的过程或例程 . 一个简单的类比将计算机编程与烤面包进行比较:您一次列出了要设置工作环境的成分,然后列出了最终要面包所必须采取的步骤. ...

  6. linux bash 变量_如何在Linux上的Bash中设置环境变量

    linux bash 变量 fatmawati achmad zaenuri/Shutterstock Fatmawati achmad zaenuri / Shutterstock There's ...

  7. python监控linux运行程序_如何在linux/tcl/python中监控正在打开或启动的应用程序?...

    我正在尝试构建一个面板应用程序,类似于avant window navigator或UbuntuUnity.在 我的问题是,一旦我用预先定义好的应用程序构建了面板,当应用程序打开或启动时,如何向面板添 ...

  8. linux加密文件_如何在Linux上使用Gocryptfs加密文件

    linux加密文件 Gocryptfs是安装在用户空间(FUSE)中的文件系统文件级加密程序. FUSE安装意味着将加密文件存储在使用FUSE接口安装的单个目录树中,就像USB密钥一样. 这样一来,任 ...

  9. linux管道使用_如何在Linux上使用管道

    linux管道使用 Fatmawati Achmad Zaenuri/Shutterstock.comFatmawati Achmad Zaenuri / Shutterstock.com Use L ...

最新文章

  1. 2022-2028年中国联合办公行业深度调研及投资前景预测报告
  2. powerdesigner生成php代码,让powerdesigner生成的sql语句在mysql上成功执行
  3. 中国的数据科学家阶层正在形成
  4. 基于Boost::beast模块的异步HTTP客户端
  5. java如何创建一个两个数的队列_java线程池 如何构建一个线程立即到拉到MAX数量跑业务,线程到MAX了,额外的队列可以存储任务的线程池...
  6. 课节6: 图神经网络进阶模型之 ERNIESage 上
  7. LinkedHashMap 底层分析
  8. 国外大牛最终还是放弃迁移到微服务,为什么?
  9. VirtualBox的ctrl键不能用
  10. adb命令刷机vivox20_求救VIVO X20的 ROOT可行的方法。
  11. PHP-阿里云oss使用
  12. Word中标题段前设置了值却不显示的解决办法
  13. 解决npm install xxx -g问题
  14. 攻克3D神器Blender的第一天-【快捷键】
  15. 设计模式-合成复用原则-》面向对象设计原则
  16. 测试排期估时多长合理?
  17. 测试用例设计工具PICT介绍
  18. linux 查看系统版本信息
  19. oracle中msdatashape,Shape. Data1 属性 (Visio)
  20. python开发桌面应用怎么样_python为什么不适合开发桌面软件?

热门文章

  1. 载荷谱、雨流计数、ncode中雨流计数的实现
  2. Vue 2 中,使用Vite作为前端构建开发工具,替代webpack(一)——vite.config.js配置文件
  3. 智能手机的终场战事:小步快跑进入“智慧时代”
  4. 中国城市三级联动数据
  5. ASP.NET 实用资料[转]
  6. 【笔记】移植ezSIFT顺手搭建个全景照片合成器
  7. 华为matebook重装win11系统后,蓝牙失效无法使用,重新安装蓝牙驱动
  8. 淘宝618叠猫猫自动逛店铺脚本
  9. ADG三种模式切换详解
  10. 用python实现解常微分方程组的简单示例以及用odeint解常微分方程的范例