Forrest logo
back to the ${command} tool

histexpand:tldr:216b6

histexpand: Run a command with the last argument of the previous command.
$ ${command} !$
try on your machine

The given command "${command} !$" is actually a combination of two separate commands joined together. Here's an explanation of each component:

"${command}" : This part is a placeholder that represents a command or a variable containing a command. It indicates that whatever is stored in the variable "command" or given as a command will be inserted into this position.

"!$" : This is a special history expansion feature in Linux command-line shells. It represents the last argument of the previous command executed.

When combined together, "${command} !$" means that the command represented by "${command}" will be executed, followed by the execution of the last argument of the previously executed command.

For example, suppose the previous command was "ls -l file.txt". If you run the command "${command} !$", it will be interpreted as "ls -l file.txt" because "${command}" represents the command "ls" and "!$" represents the last argument "file.txt" of the previous command.

This kind of command can be useful when you want to repeat a specific part of a previous command dynamically without typing it all over again.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ${command} tool