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.
Shell ScriptingUnix OS

Avatar of undefined
Last Comment
woolmilkporc

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
k3vsmith

ASKER
Thanks for the response but that doesn't seem to work. I still get all dates, not just today's date.
k3vsmith

ASKER
Hold on, confirming that I actually have a date of todays date in file, if not will add one and try again
woolmilkporc

So try

grep ^`date "+%d/%b/"` /path_to_log/access.log
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
k3vsmith

ASKER
Ok, yes its working. I dont have any with todays date. Threw me off at first. Thanks!
woolmilkporc

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.