当前位置:网站首页>sed使用心得
sed使用心得
2022-07-22 11:03:00 【panfei263031】
一直都对sed多而难记的命令望而生畏,知道他功能很强大,但是就是难掌握。sed在我脑海中一直是这样的命令:很难用,但是一旦要用的时候又不会。
首先,sed是一个编辑器,用来修改文件的,这点类似vi。但是他的特点是一行一行的处理,每读取一行,按照命令格式去处理,处理完后再读取下一行,直到按照相同的规则处理完所有行。另外,sed是根据给定的格式命令自动处理,可以快速的处理重复的编辑操作。
这种强大的命令,还是要在实践中多总结,当遇到需要用sed的场合,一定要用sed,不会就上网查。只有多实践,掌握sed的常用用法,才是正道。所以此文会持续更新。
下面结合例子展示sed的用法。
示例文件:
cv2x.ERROR $mocar_output, "/huali/log/cv2x.log"; normal
cv2x.ERROR "/huali/log/cv2x.core.log", 5MB * 1; normal
cv2x_hub.ERROR $mocar_output, "/huali/log/cv2x_hub.log"; normal
cv2x_hub.ERROR "/huali/log/cv2x_hub.core.log", 5MB * 1; normal
cv2x_stack.ERROR $mocar_output, "/huali/log/cv2x_stack.log"; normal
cv2x_stack.ERROR "/huali/log/cv2x_stack.core.log", 5MB * 1; normal
cv2x_monitor.ERROR $mocar_output, "/huali/log/cv2x_monitor.log"; normal
cv2x_monitor.ERROR "/huali/log/cv2x_monitor.core.log", 5MB * 1; normal
- 操作1:将cv2x_hub替换成cv2x_app,只打印替换后的结果,不真正修改文件内容:
- 上述操作中,只打印被替换的行,其他的行不打印:
- 上述操作中,将替换写入到文件中:
- 将包含mocar_output的行中的ERROR替换为DEBUG;
- 多点替换:将huali替换成usr,将log替换成local
- 将/huali/log一次性替换成/usr/local
边栏推荐
- Juc-6.2-concurrency container copyonwritearraylist
- 物理层2.1
- BUUCTF闯关日记02--[HCTF 2018]WarmUp1
- [lttng learning journey] - before starting
- Buuctf breakthrough diary -- [geek challenge 2019] hardsql1
- 简单句(Simple sentences)-one
- Wechat applet introduction tutorial learning notes - layout basis of UI chapter
- 3. Remote connection and SSH
- BUUCTF闯关日记--[NCTF2019]Fake XML cookbook
- Buuctf breakthrough diary --[mrctf2020]ez_ bypass1
猜你喜欢
4.文本编辑器
Buuctf breakthrough diary -- [geek challenge 2019] hardsql1
Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1
Solve the thirdscripterror error of wechat applet
[pytorch deep learning practice] learning notes section 4 back propagation
Buuctf breakthrough diary -- [netding cup 2020 Qinglong group]areuserialz
Chapter 6: EASYCODE code generator
pytorch 自定义数据集载入(标签在csv文件里)
(7) Vulhub column: log4j Remote Code Execution Vulnerability recurrence
JUC-6.3-并发容器-队列
随机推荐
Bash basic function - input / output redirection
[lttng learning journey] - simply add a trace point to the user program
[lttng learning journey] ----- core concepts
MySQL imports 300million data
pytorch 自定义数据集载入(标签在csv文件里)
Buuctf breakthrough diary -- [netding cup 2020 Qinglong group]areuserialz
[lttng learning journey] - lttng features
Set colSpan invalidation for TD of table
[lttng learning journey] - trace control -- advanced
BUUCTF闯关日记--[极客大挑战 2019]HardSQL1
Bash basic functions - Multi command sequential execution and pipeline compliance
[LTTng学习之旅]------Trace View初探
(6) Vulhub column: apereo CAS 4.x deserialization vulnerability
Bash basic functions alias and shortcut keys
【PyTorch深度学习实践】学习笔记 第四节 反向传播
Style writing in next
Solve the thirdscripterror error of wechat applet
【PyTorch深度学习实践】学习笔记 第三节 梯度下降
[LTTng学习之旅]------环境搭建
How to do research and development lean demand management well