Bash!$等价于第一个单词

dyl*_*345 0 linux bash shell command-line

有没有办法让Bash返回上一个命令的第一个单词(命令名称本身),类似于如何!$返回上一个命令的最后一个单词?

例如:

ls -l
Run Code Online (Sandbox Code Playgroud)

我想回来 ls

che*_*ner 5

您可以按编号选择单词!:.这包括任何预命令分配,因此您需要的确切数字会有所不同.

$ x=3 some_command foo   # some_command is !:1
$ ls -l                  # ls is !:0
$ x=6 y=3 bar            # bar is !:2
Run Code Online (Sandbox Code Playgroud)