Printing Content past a specific string From a file

t“tac” could be a great tool when you need to read something from backwards.  You can read a file from backward, and find the first occurrence of a string of your interest and print everything after it, that way you can get the content past a specific string from a file :

 tac /path/to/filename | grep 'word of interest' -m 1 –B <a high digit> | tac

Let me explain, firstly tac reads the file in a reverse direction just like cat does in forward direction. Then we grep the word of interest for a maximum count of 1 ( first match )  and then –B means print everyhing below it, so we pass a huge number after  -B so that we get everything we want  and at last we pass it to tac, so that it prints in the correct order.

You may also like...