Search and replace with sed when dots and underscores are present

前端 未结 5 1041
-上瘾入骨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:10

    Escape the dot with a \

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

    If you find the combination of / and \ confusing you can use another 'separator' character

    sed 's#foo\.#foo_#g
    

    The 2nd character after the s can be anything and sed will use that character as a separator.

提交回复
热议问题