Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu.

there is a way to get a list of all the commands I entered that starts with the word: "git"?

share|improve this question

migrated from Feb 14 '13 at 9:32

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

You could use history and awk together.

history | awk '$2 ~ /^git/ { print }'

Use $2 or $3 depending on the output of your history command. As Andreas pointed out, it depends on the shell that you are using. In bash, it will not include the time stamp. This can be adjusted accordingly.

share|improve this answer
history prints the time stamp at the beginning of the line, so ^ does not match – Andreas Feb 14 '13 at 8:31
@Andreas We could use awk then. Do you mean time stamp or number? – squiguy Feb 14 '13 at 8:33
Well, both of them :) history prints something like 111 8:28 git status, means that the line is at least not starting with git – Andreas Feb 14 '13 at 8:34
@Andreas Updated, now that should work better! – squiguy Feb 14 '13 at 8:40
+1 Excellent - good catch on using either $2 or $3, you could mention that it primarily depends on the shell – Andreas Feb 14 '13 at 8:43

You can either do an interactive backwards search with Ctrl+R or search your history with

history| egrep git
share|improve this answer

to know what entered in linux shell

$ history | grep 'git'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.