using sed to replace just one instance of a word/phrase on commandline

Using “sed” on command line to search/replace only one instance of a word/phrase in a file.

First, get a list of occurrences of the word/phrase using cat and grep:

cat file.ext | grep “exact word or phrase including html/code”

Choose one complete phrase or line to do the change:

sed -i ‘s~old phrase including <code>~new phrase including <html>~g’ file.ext

search-replace-using-sed