Shell generic equivalent of Bash Substring replacement ${foo/a/b}
<p>Is there a shell-independent equivalence of Bash substring replacement:</p>

<pre><code>foo=Hello
echo ${foo/o/a} # will output "Hella"
</code></pre>

<p>Most of the time I can use <code>bash</code> so that is not a problem, however when combined with <code>find -exec</code> it does not work. For instance, to rename all <code>.cpp</code> files to <code>.c</code>, I'd like to use:</p>

<pre><code># does not work
find . -name '*.cpp' -exec mv {} {/.cpp$/.c}
</code></pre>

<p>For now, I'm using:</p>

<pre><code># does work, but longer
while read file; do 
    mv "$file" "${file/.cpp$/.c}"; 
done &lt;&lt;&lt; $(find . -name '*.cpp') 
</code></pre>

<p>Ideally a solution that could be used in scripts is better!</p>