[wplug] piping grep

Matthew Beckler mbeckler at cmu.edu
Wed Jun 17 09:46:22 EDT 2009


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
> 



More information about the wplug mailing list