Search and replace with sed when dots and underscores are present

Escape the .:

sed 's/foo\./foo_/g' file.php

Example:

~$ cat test.txt 
foo.bar
~$ sed 's/foo\./foo_/g' test.txt 
foo_bar

Leave a Comment