I am doing a find and replace with sed, replacing the BASH variable $a (when at the start of a new line) with the BASH variable $b:
sed -i "s#^$a#$b#" ./file.txt
This replaces all matches for ^$a. How can I replace only the first occurrence of ^a within the entire file?
This should work:
You can read more about this at http://www.grymoire.com/Unix/Sed.html#toc-uh-29