Bash sed 命令详解

sed命令用于对文本进行过滤和变形处理。

下面是example.txt文件的内容。

Hello This is a Test 1 2 3 4
replace all spaces with hyphens

sed命令将所有的空格换成连词线-

$ sed 's/ /-/g' example.txt
Hello-This-is-a-Test-1-2-3-4

下面的命令将数字换成字母d

$ sed 's/[0-9]/d/g' example.txt
Hello This is a Test d d d d

教程来源于Github,感谢大佬的无私奉献,致敬!

技术教程推荐

移动端自动化测试实战 -〔思寒〕

容器实战高手课 -〔李程远〕

体验设计案例课 -〔炒炒〕

Go 语言项目开发实战 -〔孔令飞〕

程序员的测试课 -〔郑晔〕

林外 · 专利写作第一课 -〔林外〕

快手 · 移动端音视频开发实战 -〔展晓凯〕

B端体验设计入门课 -〔林远宏(汤圆)〕

AI大模型系统实战 -〔Tyler〕