Question

Exclude unwanted string from 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? Thanks in advance for your help!

Discussion is locked
Answer
Follow
Reply to: Exclude unwanted string from Linux grep
PLEASE NOTE: Do not post advertisements, offensive materials, profanity, or personal attacks. Please remember to be considerate of other members. If you are new to the CNET Forums, please read our CNET Forums FAQ. All submitted content is subject to our Terms of Use.
Reporting: Exclude unwanted string from Linux grep
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Comments
- Collapse -
Answer
Re: grep
- Collapse -
Answer
Exclude unwanted string from Linux grep

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/

CNET Forums