How to grep a log file by date with double space CHECKTODAY=$(date +”%b %e”)

Print Friendly, PDF & Email

You are grep ping a log file and you NEED to keep the padding in a date field.

Mystery / Misery – take your pick, until I found this page

Log file looks like this

Jul  2 10:14:28 ns380346 postfix/smtp[2179]: 00F54FFAE7: to=<mark@

Note the double space between Jul & 2, you get the padded space with %e, but where is it??

CHECKTODAY=$(date +"%b %e")
Jul 2
~# echo "$CHECKTODAY"
Jul  2


Posted in Pure Tech.

Leave a Reply

Your email address will not be published. Required fields are marked *