March 18, 2025
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.
Continue reading