re: 5 Handy Bash Tricks in 2 Minutes VIEW POST

FULL DISCUSSION
 

To piggyback on the last one there, if you history:

$ history

the output should be a numerical list of commands you've entered in the past, like so:

10016  git status
10017  git commit
10018  git push origin master

If I wanted to run git status again (ie, repeat command 10016 from history), I could do something like this:

$ !10016

 
 

You could also pipe history too! Which could allow you to grep (and more) within your history:

$ history | grep "status"

10005  git status
10008  git status
10011  git status
10014  git status
10016  git status

:)

ctrl-r status will walk back up your history looking at each time the command line contained status - just hit return when you find the command you need.

code of conduct - report abuse