当前位置:网站首页>Solve the problem of sed replacement text containing special characters such as "/" and "#"
Solve the problem of sed replacement text containing special characters such as "/" and "#"
2022-08-10 02:12:00 【Yang Linwei】
If we use the sed command, if there are special characters, an error may be reported. The example is as follows:
# / cannot be used as a delimiter, because it will conflict with the content insidesed -i 's/flink//etc/g'# pound sign# cannot be used as a delimiter, because it will conflict with the content insidesed -i 's#jdbc://127.0.0.1&password=1#aa$username=root#g'# @ cannot be used as a delimiter, because it will conflict with the content insidesed -i '[email protected]://[email protected][email protected]'
How to solve it?
We have to look inside to choose a specific delimiter, for example:
- It contains "/", you can choose "#" or "@" as a delimiter;
- It contains "#", you can choose "@" or "/" as the delimiter;
- contains "@", you can choose "/" or "#" as the delimiter.
So what if all of the above were included?The escape character "\" can only be used in the replaced text, such as:
sed -i 's/oracle/\/etc\/oracle/g'
边栏推荐
猜你喜欢
改变社交与工作状态的即时通讯是什么呢?
Mysql database ALTER basic operations
ABAP 里文件操作涉及到中文字符集的问题和解决方案
有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测
03|流程控制
[转] Typora_Markdown_图片标题(题注)
PEG derivative Biotin-PEG1-OH (cas: 95611-10-2, 2-biotinaminoethanol) advantage description
什么是一网统管?终于有人讲明白了
Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate
【无标题】
随机推荐
XSS详解及复现gallerycms字符长度限制短域名绕过
将string类对象中的内容格式化到字符串Buffer中时遇到的异常崩溃分析
MySQL最大连接数限制如何修改
@PostConsturct注解作用及特点
03|Process Control
CMake 编译运行dpdk项目程序
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative
Involved in PEG-Biotin (CAS: 1778736-18-7) Biotin-PEG4-OH is widely used in molecular target detection
assert利用蚁剑登录
UI遍历的初步尝试
-Vector Dot Product-
20220809-PotPlayer如何设置默认字体色-设置默认字体色的方法
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
走出迷宫的最少步数2
Stanford CS143 Speed Pass PA1 Tutorial
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
宝塔实测-搭建LightPicture开源图床系统
Character Statistics Histogram
使用 apxs 构建和安装 Apache 扩展共享对象模块
DHCP——动态主机配置协议