I have a problem. I want to change ole without changing dole in this file. I've tried to use:
sed -i s/^ole$/kari/ file.txtIs there any way to change this without using two command lines as:
sed -i s/^ole/kari/ file.txt; sed -i s/ole$/kari/ file.txtcat file.txt
ole duck
doffen duck
dole duck
duck, ole 2 Answers
sed -e s'/\bole\b/kari/g' file.txt
\b boundary
sed -i.bak 's/\<ole\>/new_string/g' file.txt In this case new_string would be kari (without quotes) if I understood correctly.
1