On Fri, 4 Nov 2011, frankhunt wrote: > I'm writing a script to pull some stuff out of /var/log/messages by > date. I am having problems finding any entries with a single digit date > because the messages file dates look like this: > Mmm<space><space>d for single digit dates. The output of > YESTERDAY=`date --date='yesterday'|cut -c 5-10`; echo $YESTERDAY gives > me Mmm<space>d for single digit dates. Therein lies the problem - grep > is looking for Nov 3 with one leading space while the messages file has > Nov 3 with two leading spaces. Gotta be a way to do this, I'm just not > smart enough to figure it out. Pretty sure most of you guys are . . .
GNU date will format the output pretty much any way you want. In this case, YESTERDAY=$(date -d yesterday +"%b %e %T") Search for FORMAT in the date(1) man page for other output options. -- Paul Heinlein <> [email protected] <> http://www.madboa.com/ _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
