Grep from the end of a file to the beginning
70
votes
5
answers
118003
views
I have a file with about 30.000.000 lines (Radius Accounting) and I need to find the last match of a given pattern.
The command:
tac accounting.log | grep $pattern
gives what I need, but it's too slow because the OS has to first read the whole file and then send to the pipe.
So, I need something fast that can read the file from the last line to the first.
Asked by tijuco
(831 rep)
Feb 2, 2014, 03:38 PM
Last activity: Oct 6, 2024, 10:46 AM
Last activity: Oct 6, 2024, 10:46 AM