当前位置:网站首页>解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
2022-08-10 00:33:00 【杨林伟】
如果我们使用sed命令时,如果出现特殊字符,可能会报错,示例如下:
# /不可以作为界定符,因为会与里面的内容冲突
sed -i 's/flink//etc/g'
# 井号#不可以作为界定符,因为会与里面的内容冲突
sed -i 's#jdbc://127.0.0.1&password=1#aa$username=root#g'
# @不可以作为界定符,因为会与里面的内容冲突
sed -i '[email protected]://127.0.0.1&[email protected][email protected]'
那该如何解决呢?
我们得看来里面的内容来选择特定的界定符,例如:
- 里面含有"/",可以选择“#”或“ @”作为界定符;
- 里面含有“#”,可以选择“@”或“/”作为界定符;
- 里面含有“@”,可以选择“/”或“#”作为界定符。
那么如果都有以上的内容呢?只能在被替换文本中使用转义符号 “\”了,如:
sed -i 's/oracle/\/etc\/oracle/g'
边栏推荐
猜你喜欢

02| operator

03|Process Control

有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测

Solidity最强对手:MOVE语言及新公链崛起

CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative

C语言--数据的存储(上)

Penetration Testing and Offensive and Defense Confrontation - Vulnerability Scanning & Logic Vulnerability (Part1)

【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格

XSS详解及复现gallerycms字符长度限制短域名绕过

y92.第六章 微服务、服务网格及Envoy实战 -- Envoy基础(三)
随机推荐
为什么字符串一旦创建就不可以改变?
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
PEG derivative Biotin-PEG1-OH (cas: 95611-10-2, 2-biotinaminoethanol) advantage description
egg.js中Class constructor BaseContextClass cannot be invoked without ‘new‘解决方法
Web性能测试模型小结
-Pickling peanuts-
How to turn off system protection in Win11?How to turn off the system protection restore function?
openEuler 知:abi 检测
oracle的数据导入导出
这一次,话筒给你:向自由软件之父 Richard M. Stallman 提问啦!
3.1 - 程序设计语言 3.2 - 高级语言的特点及引用 3.3 - 静态/动态类型语言
输入的这些数是否对称
字符统计柱状图
小程序实现搜索功能续
【CAS:41994-02-9 |Biotinyl tyramide】Biotinyl tyramide price
宽带由20M换为100M
pyhton之问~~~~~if __name__ == ‘__main__‘:是什么?
GB28181 sip和RTSP(Real-Time Streaming Protocol)实时流控制协议
Penetration Testing and Offensive and Defense Confrontation - Vulnerability Scanning & Logic Vulnerability (Part1)
分析 20 个 veToken 生态系统协议 这种代币模型为何受欢迎?