[PLUG] Bash question . . .
wes
plug at the-wes.com
Fri Nov 4 16:37:22 UTC 2011
On Fri, Nov 4, 2011 at 9:26 AM, frankhunt <fh-linux at frankhunt.com> 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 . . .
>
> --
> frank hunt
> (L0F) R0B-ZAR1
> befuddled linux admin
> erstwhile photographer
> hillsboro oregon
>
>
first dirty hack to spring to mind: pipe through sed "s/ / /"
-wes
More information about the PLUG
mailing list