I need to grep a log file with today\'s date, but the output is showing for more than today\'s date.
grep date +\"20%y-%m-%d\" /path/log/General.log | grep \
Just use the date
output as a pattern in grep
:
$ grep "$(date +"%Y-%m-%d")" file
2013-06-21 00:01:24,915 - INFO
2013-06-21 00:01:24,915 - INFO
That is, you need to enclose the date
sentence to make it be processed. Also, note I used Y
instead of your 20%y
.
I am looking for a sepcific
EmpID
in the logs with current date.
Then pipe to another grep:
$ grep $(date +"%Y-%m-%d") file | grep "EmpID#106496"
2013-06-21 00:01:24,915 - INFO EmpID#106496
2013-06-21 00:01:24,915 - INFO EmpID#106496