当前位置:网站首页>解决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'
边栏推荐
- Quick responsiveness intelligent/smart responsiveness of polyethylene glycol type nano/reduction response hydrogels research and preparation
- DALL·E-2是如何工作的以及部署自己的DALL·E模型
- 2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?
- JDBC数据库连接池练习题
- 鲜花线上销售管理系统的设计与实现
- assert利用蚁剑登录
- Web性能测试模型小结
- Characteristics of the (CAS:1527486-16-3TAMRA-azide-PEG3-Biotin) reaction in biotin azide!
- win10重装系统后没声音怎么办?
- 【毕业设计】 基于Stm32的家庭智能监控系统 - 单片机 图像识别 人体检测 AI
猜你喜欢

【CAS:41994-02-9 |Biotinyl tyramide】Biotinyl tyramide price

高校就业管理系统设计与实现

使用 GoogleTest 框架对 C 代码进行单元测试

2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?

渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)

Mysql database ALTER basic operations

Win11怎么关闭系统保护功能?系统保护还原功能怎么关闭?

Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate

数据建模已死,真的吗?

嵌入式Qt-实现两个窗口的切换
随机推荐
DHCP——动态主机配置协议
20220808-一些想法
即时通讯开发如何撸一个WebSocket服务器
使用 GoogleTest 框架对 C 代码进行单元测试
将string类对象中的内容格式化到字符串Buffer中时遇到的异常崩溃分析
Solving for the number of mines
How to activate the payment function on WeChat official account?
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
【kali-密码攻击】(5.1.2)密码在线破解:Medusa
Biotin-Cy2 Conjugate, Biotin-Cy2 Conjugate_Cy2 Biotin Conjugate
【Django】缓存
Minimum number of steps to get out of the maze 2
03|Process Control
Solidity 智能合约入门
Quick responsiveness intelligent/smart responsiveness of polyethylene glycol type nano/reduction response hydrogels research and preparation
3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法
开发IM即时通讯容易吗?需要什么技术
头脑风暴:单词拆分
Pyscript,创建一个能执行crud操作的网页应用
02|运算符