Search and replace with sed when dots and underscores are present

前端 未结 5 1044
-上瘾入骨i
-上瘾入骨i 2020-12-03 04:51

How do I replace foo. with foo_ with sed simply running

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

doesn\'t work. Thanks!

5条回答
  •  北海茫月
    2020-12-03 05:15

    Escape the .:

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

    Example:

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

提交回复
热议问题