I have a file like this:
string log 1
string log 2
string match
string log 4
string match
string log 5
string log 6
I need to get all the lines after the last string match. How can I do it in bash?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|
First, find the last string match:
Then, print all lines up to that last string match:
If you need all lines after last match:
|
||||
|
|
|
I would personally use this sed method:
|
|||
|
|
|
|
This might work for you:
|
|||
|
|
|
I'm going to assume in bash allows for some external binary calls. With that in mind: All lines after the last match
Output
All lines before the last match
Output
|
|||||||||
|