I am trying to use grep to go through some logs and select only the most recent entries. There are many years of heavy traffic in magazines, so it's silly to
tac error.log | grep 2012 tac error.log | grep "Jan.2012"
and etc.
and wait 10 minutes for it to go through several million lines, which, as I already know, do not match. I know that the -m option exists to stop in the first match, but I don't know how to stop it in the first match. I could do something like grep -B MAX_INT -m 1 2011 , but this is hardly the optimal solution.
Can grep handle this or will awk make more sense?
source share