[ale] Reverse of the 'cut' program
DJ-Pfulio
DJPfulio at jdpfu.com
Tue Feb 10 18:03:45 EST 2015
I always think of egrep as "enhanced grep" ... it uses the fuller regex engine
compared to what normal grep uses. From the manpage:
-E, --extended-regexp
Interpret PATTERN as an extended regular expression (ERE, see
below). (-E is specified by POSIX.)
It goes on to say that there isn't any difference in the specific implementation
on my Ubuntu box between basic and extended regex option. However, other
implementations may still have those differences. It is possible to have egrep
use perl-regex, which are much extended, if pcre is available in the system.
If it isn't clear, full perl regex syntax is A-W-E-S-O-M-E. It is possible to
actually document a 50 line regex, if you need that complexity. ;)
On 02/10/2015 05:19 PM, Lightner, Jeff wrote:
> Just to tie it together since OP indicated the "grep -v" worked. There is a difference beween "grep" and "egrep" (a/k/a grep -E in some UNIX flavors):
>
> "grep -v <pattern>" lets you exclude a SINGLE pattern.
>
> "egrep -v "<pattern1>|<pattern2>|<etc...>" excludes each pattern defined where the pipe symbol means "or".
>
> "grep -v google.com" works to exclude google.com.
> "grep -v "yahoo.com" works to exclude yahoo.com.
>
> egrep -v "google.com|yahoo.com" excludes both.
>
> Also FYI: -vi instead of just -v will exclude without case sensitivity.
> "grep -vi google.com" excludes "google.com", "GOOGLE.COM", gOoGlE.cOm, etc... whereas without the -i it would exclude only the case you specified.
>
>
>
> -----Original Message-----
> From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of DJ-Pfulio
> Sent: Tuesday, February 10, 2015 5:07 PM
> To: Atlanta Linux Enthusiasts
> Subject: Re: [ale] Reverse of the 'cut' program
>
> egrep -v 'regex1|regex2|regex3' ....
>
> Or you can pipe the output through egrep -v a few times to remove more and more lines.
>
> Sure, you can use a scripting language, but why? BTW - I'd use perl. ;)
>
> On 02/10/2015 02:22 PM, Pete Hardie wrote:
>> grep -v <exclude pattern>
>>
>> On Tue, Feb 10, 2015 at 2:16 PM, Justin Goldberg <justgold79 at gmail.com
>> <mailto:justgold79 at gmail.com>> wrote:
>>
>> I am trying to parse a log file and exclude the lines that contain any one
>> of a few different strings, for example "don't show ones that contain
>> google.com <http://google.com> or ones that yahoo.com <http://yahoo.com>"
>> for example.
>>
>> I'm guessing that sed or awk would fit this purpose.
>>
>> I looked on the web but didn't find any examples that made sense to this
>> Linux newbie.
>>
>> Any replies or pointers will be greatly appreciated!
--
Got Linux? Used on smartphones, tablets, desktop computers, media centers, and
servers by kids, Moms, Dads, grandparents and IT professionals.
More information about the Ale
mailing list