Tuesday, 15 May 2012

logging - Grep a log file with current date -


I need to griddle a log file with today's date but the output is shown for more than today's date. grep date + "20% y-% m-% d" /path/log/General.log | Grep "EmpID # 106496" /path/log/Genral.log

Output:

  2013-06-19 14: 47: 05,996 - Information EmpID # 106496 2013-06-19 14: 47: 05,996 - Information EmpID # 106496 2013-06-21 00: 01: 24,915 - Information EmpID # 106496 2013-06-21 00: 01: 24,915 - Information EmpID # 106496   

just type date in the form of a pattern in grep Use in :

  $ grep "$ (date +"% Y-% m-% d ")" file 2013-06-21 00: 01: 24,915 - Information 2013-06-21 00: 01: 24,915 - info   

That is, to include the code, you have to include the date Will. Also, note that I have used y instead of your 20% y .


I have a valid EmpID

-% d ") file | Grep" EmpID # 106496 "2013-06-21 00: 01: 24,915 - Information EmpID # 106496 2013-06-21 00: 01: 24,915 - Information EmpID # 106496

No comments:

Post a Comment