bash命令中!#:*!#:1-是什么意思? [英] What is the meaning of !#:* !#:1- in a bash command?

查看:229
本文介绍了bash命令中!#:*!#:1-是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的Bash命令中,!#:* !#:1

In the following Bash command, what is the meaning of: !#:* !#:1

echo "This is a sentence." !#:* !#:1- >text3

推荐答案

它正在使用 bash的历史替换机制.

具体地说,!#是指当前行(直到但不包括!#本身的位置). !#:*是该命令名称后该行的一部分(因此,在本例中为"This is a sentence."). !#:1-!#:*相同,除了它省略了最后一个单词(因此它不包括我们刚刚通过!#:*添加的"This is a sentence"的第二个副本).

Specifically, !# refers to the current line (up to but not including the location of the !# itself). !#:* is the part of that line after the command name (so, in this case, "This is a sentence."). !#:1- is the same as !#:* except that it omits the last word (so it doesn't include the second copy of "This is a sentence" that we just added via the !#:*).

最终结果是一行包含三个This is a sentence.副本的行,回显到名为text3的文件中.

The end result is a line with three copies of This is a sentence. echoed into a file named text3.

这篇关于bash命令中!#:*!#:1-是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆