📎 AI Summary:
The thread discusses how to use Linux `grep` to search for specific lines in a configuration file while excluding certain strings. The original poster asks for guidance on excluding particular strings during a search, and a contributor suggests using piped `grep` commands with the `-v` option to exclude matches. Overall, the conversation provides practical solutions for filtering text in Linux, with an emphasis on understanding `grep` and regular expressions.

Gabriel Turqos

Active Member
Member details
Joined
Mar 11, 2019
Messages
17
Thread Author #1
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!
 

Solution
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.

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,994
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.
 
Solution