LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Extract every record except (https://www.linuxquestions.org/questions/linux-newbie-8/extract-every-record-except-4175527193/)

battles 12-03-2014 08:01 AM

Extract every record except
 
I know how to extract every record that contains a pattern:

grep "404" <f1> > <f2>

But is there a way to extract every record that doesn't contain the pattern?

Thanks.

gdejonge 12-03-2014 08:28 AM

Hi,

Read the man page of grep and pay special attention to the -v option.


Cheers,

battles 12-03-2014 08:59 AM

Thanks. Just to leave an example:

echo "$(grep -v "\*" <f1>)"

This displayed every line in file <f1> that didn't contain an asterisk.


All times are GMT -5. The time now is 08:49 AM.