Is there a way to start the grep
search from the end of the file instead of the beginning? Here is from the beginning --
$ grep -irn 'Qyt13_pUFjQ' ./
The information that I am looking for is close to the end of the file, but takes a few minutes to get all the way there from the start.
Matching the lines that end with a string : The $ regular expression pattern specifies the end of a line. This can be used in grep to match the lines which end with the given string or pattern.
To look at the last few lines of a file, use the tail command. tail works the same way as head: type tail and the filename to see the last 10 lines of that file, or type tail -number filename to see the last number lines of the file.
The grep command searches through the file, looking for matches to the pattern specified. To use it type grep , then the pattern we're searching for and finally the name of the file (or files) we're searching in.
Add the -v option to your grep command to invert the results. Save this answer.
You can use tac
to read the file line by line from the end to the beginning, then possibly switch it around again with another tac
if you need to.
You can do tail -n xxxx file.txt | grep ...
to pipe the last xxxx lines of the file through grep.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With