Instantly share code, notes, and snippets.
This comes from StackOverflow. Some people there suggested using sed '0,/string/ s/string/replacement' but this didn't work for me on OS X 10.9.
sed '0,/string/ s/string/replacement'
Solution sed 's/string/replacement/1' works as well, in case of one occurrence of the string per line. Otherwise, sed will replace all occurrences of the string within the first line where it's found.