Rerun a Command That Starts with a given String

To run the most recent command that begins with a given string, use an exclamation mark followed by that string. For example, to run the last command that started with a “d”, type “!d“. Specify as much of the string to make it unique. If you have several commands in your recent history that begin with “d”, you can add additional characters, like “!du” or “!df“.

I find myself using this technique to get a status, perform some work that might affect that status, and to recheck the status again. Here is an example where data is being copied to a file system and where the disk usage is being checked.

Syntax:

!

Examples:

!d
!du
!df
Linux strings