且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从linux grep中排除不需要的字符串

更新时间:2022-10-16 08:21:29

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/