Linux Exclude unwanted string from Linux grep

Gabriel Turqos

Active Member
Mar 11, 2019
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!
I think you have more chances to find the answer on Stackoverflow.
Specifically using grep you'd need to pipe one grep to another such as say you want to find occurrences of 'car' but not 'racecar'

grep 'car' /home/user/somefile.txt | grep -v 'racecar'

It would be a shorter command if you used egrep but you'd need to understand regex expressions to make correctly.
Top Bottom