linux - 使用 sed "s| ACT: ||"

标签 linux bash unix

<分区>

我是 linux 初学者。虽然我已经了解了 sed 命令的不同语法,但仍然无法理解这种形式:

sed "s|key:  ||"

请有人帮助我理解这种形式的 sed,这里的键可以是任何单词。 我很困惑,它是如何将这里的 key 替换为某些东西的?

最佳答案

这是 info sed :

The 's' command (as in substitute) is probably the most important in 'sed' and has a lot of different options. The syntax of the 's' command is 's/REGEXP/REPLACEMENT/FLAGS'.

The '/' characters may be uniformly replaced by any other single character within any given 's' command. The '/' character (or whatever other character is used in its stead) can appear in the REGEXP or REPLACEMENT only if it is preceded by a '\' character.

这意味着您可以使用 s/foo/bar/g , s|foo|bar|g , s#foo#bar#g , skfookbarkg或任何其他字符,它们都表示同一件事。 /仅仅是常规的。

(有趣的事实:这意味着一些英语单词,如 streetlightserenadesynonymously 是有效的 sed s 命令。)

关于linux - 使用 sed "s| ACT: ||",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52374114/

相关文章:

linux - awk 三重文件输入

linux - 关于 lz4mt 压缩和 linux 缓冲问题

python - 使用来自 bash 的变量输入执行一行 python

build-process - 设置强大的中小型项目的教程 *nix build

java - 如何使用Unix重定向在滚动文件中重定向stdout和stderr

c++ - 将 FILETIME 转换为可移植时间单位

linux - 用不同的用户重启 Rabbitmq 集群

python - 了解 Python fork 和内存分配错误

python - 直接通过url使用python从imgur下载文件

c - 在ncurses/C中模拟bash "snow fall"脚本