grep without string

Either of the these will do:

grep -v "def" input_file | grep "abc"

or

grep "abc" input_file | grep -v "def"

The following will also preserve coloring if you only want to see the output on stdout:

grep --color=always "abc" input_file | grep -v "def"

The -v option (stands for “invert match”) tells grep to ignore the lines with the specified pattern – in this case def.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)