Skip to content

Instantly share code, notes, and snippets.

@skarabasakis
Created April 18, 2014 09:35
Show Gist options
  • Save skarabasakis/d6e9c1ab0baa24d3d82e to your computer and use it in GitHub Desktop.
Save skarabasakis/d6e9c1ab0baa24d3d82e to your computer and use it in GitHub Desktop.
Reusing bash history with bangs
$ !! # Repeat last command
$ !x # Repeat last command that started with x
$ !?x # Repeat last command that has the substring x
$ !10 # Repeat 10th command in the history file
$ !-10 # Repeat 10th from last command in the history file
$ !!* # Fetch parameters from last command
$ !!^ # Fetch first parameter from last command
$ !!$ # Fetch last parameter from last command
$ !!3 # Fetch third parameter from last command
$ !!:s/foo/bar/ # Repeat last command substituting foo for bar
$ !!:p # Print last command without running it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment