gpt4 book ai didi

linux - 单个感叹号对 bash 历史事件指示符意味着什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:36:17 24 4
gpt4 key购买 nike

我刚刚读到关于 Event Designators 的内容在 bash 文档中,但是 !:gs/foo/bar 也可以,它应该是 !!:gs/foo/bar 吗?文档说

! Start a history substitution

所以这也意味着引用了最后一个命令行?或者这里 ! 只是 !string in !:gs/foo/bar 的边缘情况,当 string 是空的?仅供引用 ^old^new 等同于 !!:s/old/new/^old 等同于 !!:s/old//

最佳答案

section about Word Designators 的末尾,手册说

If a word designator is supplied without an event specification, the previous command is used as the event.

这意味着如果您只使用 ! 和诸如 :2 之类的指示符,则 !:2 将被解释为 !!:2。单词指示符是可选的,因此如果您仅使用修饰符(如在您的 !:gs/foo/bar 示例中),同样适用:扩展适用于前一个命令。

关于linux - 单个感叹号对 bash 历史事件指示符意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48625974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com