The reverse grep

Grep –v  stand for inverse.  With grep –v you can extract lines that correspond to the opposite of your search criteria.

Let suppose a file name “name” that contain the name of many people , here is what it contain:

Dany Moore

Steve Hawkins

Roger Hipkiss

Loy Hinton

Mandy Moore

Candy Diaz

Fernando Diaz

If you do :

1

cat name | grep –v moore

you will get :

Steve Hawkins

Roger Hipkiss

Loy Hinton

Candy Diaz

Fernando Diaz

Or you can do :

2

grep –v moore name

About the Author

Stephane Morin

Sign up for more great content!