Skip to content

Instantly share code, notes, and snippets.

@DiamondI
Created September 29, 2020 06:24
Show Gist options
  • Save DiamondI/2dc69e530c48dfeb733562040e53f4b0 to your computer and use it in GitHub Desktop.
Save DiamondI/2dc69e530c48dfeb733562040e53f4b0 to your computer and use it in GitHub Desktop.
[用sed做文本替换] #sed #terminal

用sed做文本替换

sed做文本替换的语法如下:

语法

sed 's/old/new/g'

例子

如果要删去文本中的冒号,并且将结果输出到新的文本文件中的话,可以这样写:

cat old.txt | sed 's/://g' > new.txt

注意:g前面的两个斜杠是要将冒号替换成空字符的缘故。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment