从linux grep中排除不需要的字符串 [英] Exclude unwanted string from linux grep

查看:1274
本文介绍了从linux grep中排除不需要的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单文本的配置文件。我想列出一些配置行,但除了一些配置。如何使用Linux grep排除和搜索给定的字符串?



我尝试过的方法:



我有一个配置文件是一个简单的文本。我想列出一些配置行,但除了一些配置。如何使用Linux grep排除和搜索给定的字符串?在此先感谢您的帮助!

解决方案

man grep 会告诉您。



grep -v模式文件将为您提供文件中的行 t包含模式


给定文本文件或输入流有不同的排除和grep方法。我通常更喜欢使用两个grep的最基本的一个,其中第一个用于使用-v选项排除,而管道用于第二个用于grep我的字符串。 grep -v'能'config.txt | grep'ystem'有关详细信息,请参阅 https://www.poftut.com/introduction -to-Linux的grep的命令与 - 实例/

I have a configuration file which is a simple text. I want to list some configuration line but except some sitring. How can I use Linux grep to exclude and search for given strings?

What I have tried:

I have a configuration file which is a simple text. I want to list some configuration line but except some sitring. How can I use Linux grep to exclude and search for given strings? Thanks in advance for your help!

解决方案

man grep would tell you.

grep -v pattern file will give you the lines in file that don't contain pattern


There are different ways to exclude and grep given a text file or input stream. I generally prefer the most basic one where use two grep where the first one is for exclude with -v option and pipe to second one where I grep for my string. grep -v 'able' config.txt | grep 'system' For more information look https://www.poftut.com/introduction-to-linux-grep-command-with-examples/


这篇关于从linux grep中排除不需要的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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