当出现点和下划线时,搜索并替换sed [英] Search and replace with sed when dots and underscores are present

查看:117
本文介绍了当出现点和下划线时,搜索并替换sed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更换foo。带有foo_和sed简单运行

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

无法使用。
感谢!

解决方案

逃离

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



示例:

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


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

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

doesn't work. Thanks!

解决方案

Escape the .:

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

Example:

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

这篇关于当出现点和下划线时,搜索并替换sed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆