1

I have 2.5GB catalina.out file. I need to extract the current date's logs from this file. See below my log file format:

2016-02-15 19:49:45 INFO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2016-02-15 19:49:52 INFO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.
.
.
2016-04-06 07:49:52 INFO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1 Answer 1

1

You can do:

grep "^$(date -I)" /path/to/log

date -I will give today's date in YYYY-MM-DD format just like the logfile has at the start of each line.

2
  • Yes superb.Thanks for your Prompt Response.I found from my side "cat file | grep date +%Y-%m-%d>currnt.txt " Apr 6, 2016 at 6:51
  • @GulabSherieff My one is short date from of yours one just without the useless cat..Also your one will match any anywhere in the line, not just at the start of teh line..please select my answer as accepted by clicking the tick mark on the left of my answer so that this issue can be marked as solved..
    – heemayl
    Apr 6, 2016 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .