In the BASH shell, you can use the !$
history expansion to insert the last argument of the previous command into the current input line.
For example, if you have previously entered the following command:
ls /usr/local/binSruoce:www.lautturi.com
To list the contents of the /usr/local/bin
directory, you can use the !$
history expansion to copy the last argument of the previous command into the current input line:
ls !$
This will insert /usr/local/bin
into the current input line, resulting in the following command:
ls /usr/local/bin
You can also use the !!
history expansion to insert the entire previous command into the current input line.
For example, to copy the previous command and run it again, you can use the !!
history expansion:
!!
This will insert the entire previous command into the current input line and run it again.
Keep in mind that these history expansions are just a few examples of how you can use the BASH history to save time and improve productivity. You can use the history
command to view the list of previously entered commands and use other history expansions to modify and reuse them. For more information, you can refer to the bash
man page or the BASH documentation.