awk
is always handy for these cases:
$ awk '/2/ {p=1; next} p{a=$0; p=0} END{print a}' file
file abc
Explanation
/2/ {p=1; next}
when2
appears in the line, activate thep
flag and skip the line.p{a=$0; p=0}
when thep
flag is active, store the line and unactivatep
.END{print a}
print the stored value, which happens to be the last one becausea
is always overwritten.