Link to home
Start Free TrialLog in
Avatar of k3vsmith
k3vsmith

asked on

grep for a current date in a particular format

This is RHEL 5 os. I'm using bsh.
I am trying to grep a log for the current date.
The way the log records the date is in this format:
02/Apr/2015:11:38:44

How do I grep for the current day and month? The rest of the date doesn't matter.

So far this is my command:
grep page.jsp /path_to_log/access.log | grep 404

Id like to include only to search for todays date as I dont care about past dates.

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k3vsmith
k3vsmith

ASKER

Thanks for the response but that doesn't seem to work. I still get all dates, not just today's date.
Hold on, confirming that I actually have a date of todays date in file, if not will add one and try again
So try

grep ^`date "+%d/%b/"` /path_to_log/access.log
Ok, yes its working. I dont have any with todays date. Threw me off at first. Thanks!
If there is no date of todays date in file then you should have seen no output at all.

Please try the above "backtick" version, if needed without the caret.