Glam Prestige Journal

Bright entertainment trends with youth appeal.

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.

2 Answers

Try

grep -v '[834]' file

From man grep

 -v, --invert-match Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)
6

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

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy