Tuesday, July 28, 2009

UNIX question: I don't get grep-v? What does it do?

Learning UNIX for a class and we're supposed to answer questions on grep -v, but it is not in our class material. I've had no luck googling it. Can somene explain it to me or point me to a website that explains it? We're using the bash shell if that helps.

UNIX question: I don't get grep-v? What does it do?
From the man pages:





" -v, --invert-match





Invert the sense of matching, to select non-matching lines."





usage would be





grep -v "this" [FILE] would return all lines not containing the phrase "this".





Note that Unix has a very powerful help capability. Type in "man %26lt;command%26gt;", and you will get a full definition of the command and all the parameters. Very useful whether you are learning Unix or have a good background in it already.
Reply:I just wanted to say you answered the last question eloquently and I love ya for it!
Reply:You probably have a "man" command on that Unix machine. You can usually type





man grep





and get a listing of options and such.





The other answers here are correct about the -v option.
Reply:Returns all lines in a file NOT containing the string variable.

clinton cards

No comments:

Post a Comment