原文链接
语法
sed 's/serach_str/replace_str/g' file_path
在某个文件中查找所有的serach_str并替换为replace_str
| 参数 | 描述 |
|---|---|
| serach_str | 要搜索的字符串 |
| replace_str | 用于替换搜索到的字符串 |
| file_path | 文件路径 |
用法举例
sed 's/to/too/g' my.txt
在
my.txt文件中查找所有的to并用too替换掉
sed 's/serach_str/replace_str/g' file_path
在某个文件中查找所有的serach_str并替换为replace_str
| 参数 | 描述 |
|---|---|
| serach_str | 要搜索的字符串 |
| replace_str | 用于替换搜索到的字符串 |
| file_path | 文件路径 |
sed 's/to/too/g' my.txt
在
my.txt文件中查找所有的to并用too替换掉