How to grep lines from a log file that have the current date?

前端 未结 3 2049
一生所求
一生所求 2021-01-21 05:37

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 \         


        
3条回答
  •  轮回少年
    2021-01-21 06:04

    If you need to add space delimited fields in date command use double quotes around $() :

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

提交回复
热议问题