[wplug] piping grep

Arnaud lists at arnaudloos.com
Wed Jun 17 10:48:01 EDT 2009


Thanks. That worked. I wasn't taking into account that the date result had a
space in it and needs to be passed to grep in quotes.


-----Original Message-----
From: wplug-bounces+lists=arnaudloos.com at wplug.org
[mailto:wplug-bounces+lists=arnaudloos.com at wplug.org] On Behalf Of Matthew
Beckler
Sent: Wednesday, June 17, 2009 9:46 AM
To: General user list
Subject: Re: [wplug] piping grep

Whoops, sorry for the double-post. I should have actually tested this
before posting. I think you actually need to have the double-quotes
outside the backticks:

grep 'Failed password' /var/log/auth.log | grep "`data +'%b %d'`"

--
Matthew

Matthew Beckler wrote:
> Perhaps I'm not fully understanding the problem, but I would try putting
>  backticks around the "data +'%b %d'". This should cause bash to
> evaluate the sub-expression (the call to date), and then use the result
> in the grep, like this:
> 
> grep 'Failed password' /var/log/auth.log | grep `"data +'%b %d'"`
> 
> --
> Matthew
> 
> 
> Arnaud wrote:
>> I'm trying to craft a bash statement that will output all the failed ssh
>> connections for the current day. The auth log starts each entry with a
date
>> stamp like "Jun 17".
>>
>> This gives me my desired output:
>> grep 'Failed password' /var/log/auth.log | grep 'Jun 17'
>>
>> And so I assumed this would too:
>> grep 'Failed password' /var/log/auth.log | grep "date +'%b %d'"
>>
>> I know I'm having a problem with the nested quotes but I'm not sure how.
Can
>> someone set me straight.
>>
>> Thanks.
>> Arnaud-
>>
>> _______________________________________________
>> wplug mailing list
>> wplug at wplug.org
>> http://www.wplug.org/mailman/listinfo/wplug
>>
> 
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
> 

_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug



More information about the wplug mailing list