Given a file like this:
a b a b
I\'d like to be able to use sed to replace just the last line that contains an instance of \"a
sed
Another approach:
sed "`grep -n '^a$' a | cut -d \: -f 1 | tail -1`s/a/c/" a
The advantage of this approach is that you run sequentially on the file twice, and not read it to memory. This can be meaningful in large files.