Shell ! command
!!
is well known to repeat the last shell command in a *nix terminal, it turns out there are other useful variants:
Given a shell history:
$ history
10034 echo $PATH
10035 history
10036 type ruby
10037 which ruby
10038 history
10039 ls
!n
- execute a specific item:
$ !10039
ls
Applications
Desktop
...
!?<match>?
: matches a pattern and runs the first command that matches:
$ !?uby?
type ruby
ruby is /Users/jason/.rvm/rubies/ruby-2.2.2/bin/ruby
````
Tweet