Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Mmmm...regular expressions. (was Re: Bash shell line continu



On 14-Sep-2001 Shimpei Yamashita wrote:
> On Fri, Sep 14, 2001 at 11:49:56AM +0900, brettr wrote:
>> grep -vi \.gif ex010905.log | grep -vi \.jpg | grep -vi \.jpeg |     /
>>            grep -vi 'googleboot |openfind  > summary.log
> 
> I think you meant to say 
> 
>   grep -vi '\.gif' .... 
> 
> or  
> 
>   grep -vi \\.gif ....
> 
> Shells eat unquoted or unescaped backslashes, so grep will only see
> .gif in your example.
> 
> You may also want to use '\.gif\b' instead of '\.gif' -- that way, the
> expression will only match .gif at the end of a word, and you won't
> drop lines containing words like big.gift.html on the floor. (If you
> aren't running Linux, you may have to use egrep instead of grep to get
> this feature.)

Regular expressions are by no means within my area of expertise, but
wouldn't it be more efficient to do something like:

grep -vi '\.gif\b|\.jpg\b|\.jpeg\b|googleboot' ex010905.log|openfind > \
summary.log

It seems I can never get these alternation patterns correct. Perhaps someone
can correct this for me.
______________________________________________________________________
Stuart Luppescu         -=-=-  University of Chicago
$(B:MJ8$HCRF`H~$NIc(B        -=-=-  s-luppescu@example.com
http://www.consortium-chicago.org/people/sl.html
http://musuko.uchicago.edu/pubkey.asc for PGP Public Key
ICQ #21172047  AIM: psycho7070
When a woman gives me a present I have always two surprises:
first is the present, and afterward, having to pay for it.
                -- Donnay
>> Sent on 14-Sep-2001 at 09:00:59 with xfmail


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links