Could someone explain to me what !d
command does?
It seems to recall an old command (du -sh
for me) but I have no idea how this command is chosen.
Could someone explain to me what !d
command does?
It seems to recall an old command (du -sh
for me) but I have no idea how this command is chosen.
!
is event designator in bash. You can read more about it here https://alexbaranowski.github.io/bash-bushido-book/#event-designator-word-designator-modifiers (this is my own book about bash and tricks).
!STRING
will invoke the last command starting with STRING.
Edit: Excerpt from the link/book:
To invoke the last command that starts with a given string, use the event designator with a string so that the command looks like !<string>
. Example below:
[Alex@SpaceShip cat1]$ whoami
Alex
[Alex@SpaceShip cat1]$ who
Alex :0 2018-04-20 09:37 (:0)
...
[Alex@SpaceShip cat1]$ !who
who
Alex :0 2018-04-20 09:37 (:0)
...
[Alex@SpaceShip cat1]$ !whoa
whoami
Alex
According to the manual 9.3.1 Event Designators:
!string
Refer to the most recent command preceding the current position in the history list starting with string.