I'm tying to replace the last occurrence of a word in a file.
hello
bye
bye
bye
hello
I am able to replace it by indicating the line number.
sed -i '4 s/bye/adieu' file
Also, if the occurrence is in the last line.
sed -i '$ s/hello/salut' file
But, how can I find and replace the last bye
without indicating the line number?