Bash Bang (!) commands

Re-run all or part of a previous command.

Syntax
      !!       Run the last command again

      !foo     Run the most recent command that starts with 'foo' (e.g. !ls)

      !foo:p   Print out the command that !foo would run
               also add it to the command history

      !$       Run the last word of the previous command (same as Alt + .)

      !$:p     Print out the word that !$ would substitute

      !*       Run the previous command except for the last word

      !*:p     Print out the previous command except for the last word

     ^foo^bar  Run the previous command replacing foo with bar

“This is the way the world ends. Not with a bang but a whimper” - T.S. Eliot (The Hollow Men)

Related macOS commands

Bash keyboard commands


 
Copyright © 1999-2024 SS64.com
Some rights reserved