[wplug] piping grep

Vance Kochenderfer vkochend at nyx.net
Wed Jun 17 23:05:10 EDT 2009


Can't resist throwing in my two cents - here's how I'd do it:
  grep "^`date +'%b %_d'`.*Failed password" /var/log/auth.log

This regex lets you avoid calling grep twice.  Also, using %_d is
necessary in the date format so it will space-pad the day of month
(e.g., "Jan  3" - %d would result in "Jan 03" which doesn't match
the log format sshd uses).

If the lastb command works on your system, you could also try:
  lastb | grep "`date +'%b %_d'`"

Vance Kochenderfer        |  "Get me out of these ropes and into a
vkochend at nyx.net          |   good belt of Scotch"    -Nick Danger


More information about the wplug mailing list