Last Updated: July 05, 2016
·
241
· muquiutti

Replace word with SED

sed -i 's/wordtoreplace/wordreplaced/g' namefile

1 Response
Add your response

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

over 1 year ago ·