当前位置:网站首页>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'
边栏推荐
- PEG 衍生物Biotin-PEG1-OH(cas:95611-10-2,2-生物素氨基乙醇)优势说明
- mstsc/Mstsc (Microsoft terminal services client)远程桌面连接
- 365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy
- 基于Web的疫情隔离区订餐系统
- 五种定位——粘性定位
- Stanford CS143 Speed Pass PA1 Tutorial
- JVM :运行时数据区-虚拟机栈
- CMake 编译运行dpdk项目程序
- 惊掉你下巴,程序员编码竟然可以被 996 指数化
- Sikuli 基于图形识别的自动化测试技术
猜你喜欢
随机推荐
将string类对象中的内容格式化到字符串Buffer中时遇到的异常崩溃分析
嵌入式Qt-实现两个窗口的切换
这一次,话筒给你:向自由软件之父 Richard M. Stallman 提问啦!
【软考软件评测师】软件测试基础知识
XSS详解及复现gallerycms字符长度限制短域名绕过
Web性能测试模型小结
c语言文件基本操作总结
即时通讯开发如何撸一个WebSocket服务器
eyb:Redis学习(4)
宽带由20M换为100M
使用 apxs 构建和安装 Apache 扩展共享对象模块
hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
UI遍历的初步尝试
-向量点积-
CAS:851113-28-5 (生物素-ahx-ahx-酪胺)
基于SSM实现手机销售商城系统
CAS:851113-28-5 (Biotin-ahx-ahx-tyramine)
什么是一网统管?终于有人讲明白了
【报错】ModuleNotFoundError: No module named ‘scp‘
FITC标记生物素(FITC-生物素|CAS:134759-22-1)有哪些知识了?