Ubuntu – Grep printing a line that doesn’t contain a set of numbers

grep

I'm trying to get Grep to print all lines in a txt file that do not contain the numbers 834. When I try "grep [^834] file.txt" it still prints all the lines containing 834 but just doesn't highlight them.

Best Answer

You ask grep to print all lines that contain a pattern consisting of a character that is not a 8, 3 or 4. Depending on what your file consists of, this will probably find almost anything. To show "everything but" grep has the -v switch. E.g. something like grep -v "8\|3\|4" should work. Or if you specifically want to throw out the number 834: grep -v 834

Related Question