You should also consider word boundaries is you want to replace whole words. => sed -i 's/\bwordtoreplace\b/wordreplaced/g' namefile
without \b echo 'this is a test' | sed 's/is/banana/g' thbanana banana a test
with \b echo 'this is a test' | sed 's/\bis\b/banana/g' this banana a test
You should also consider word boundaries is you want to replace whole words.
=> sed -i 's/\bwordtoreplace\b/wordreplaced/g' namefile
without \b
echo 'this is a test' | sed 's/is/banana/g'
thbanana banana a test
with \b
echo 'this is a test' | sed 's/\bis\b/banana/g'
this banana a test