I would like to remove unwanted lines from my text file had certain words. i have use grep -v like this
grep -v 'error|fault|unkownn' input.txt > out.txt
it's working with one word but not on multiple words. did i miss anything?
| is only treated as a a regex character when grep is working in extended regex mode. So you need to do one of the following:
# Escape the | so that it's treated as a regex control character
grep -v 'error\|fault\|unkownn' input.txt > out.txt
# -E enables extended regex mode
grep -vE 'error|fault|unkownn' input.txt > out.txt
# egrep = grep -E
egrep -v 'error|fault|unkownn' input.txt > out.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With