tac -- the ignored reverse of cat
When grep
a very large log file to find the last occurrence of some string, it is much than efficient to back iterate the files from the last line than methods using tail
or tail -n
.
And I just found tac
from coreutils, best suiting the job. tac
is the reverse of cat
, the job I mentioned above can be done via:
tac very-large-log-file.log|grep -m 1 some-string
This is very useful. And most important thing is that I didn’t realize the solution is lying there ignored in the coreutils
all the time.