[ale] Reverse of the 'cut' program
Lightner, Jeff
JLightner at dsservices.com
Tue Feb 10 17:19:25 EST 2015
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.
_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
See JOBS, ANNOUNCE and SCHOOLS lists at
http://mail.ale.org/mailman/listinfo
More information about the Ale
mailing list