I have a file, file.txt, like this:
start cal
end cal
start eff
end eff
start cal
error
end cal
start dod
end dod
What I want to get is the line between the last set of 'start cal' and 'end cal'. I am using tac and grep to do it. But in vain. Any help please? Below is my code:
tac file.txt | grep -m1 'start cal*end cal'
What am I doing wrong? For the example above, I need the command to return 'error'.