Finding a solution for this was bordering on ridiculous, no matter how I put it… “replace using non greedy”, “replace only one instance of a string”, “replace first string match only” I struggled to find an answer. The man page had no information on this either. After a while I came up with the following solution.
sed '0,/this/s//to_that/' filename.txt
It was able to replace the first occurrence of the string “only” as I wanted (regardless of which line it was on etc), however I had no idea how I did it. After I had finished, I Tweeted for some assistance on how this actually works, a colleague sent me the following link which is quite comprehensive.