Linux Exclude unwanted string from Linux grep

Gabriel Turqos

New Member
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!
 

Neemobeer

Windows Forum Team
Staff member
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