Server Fault is a question and answer site for system and network administrators. 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

Is there a way that I can remove repeated commands from bash history?

For example: I run the mv command once, then I run the ls command n times.

I have to press the up arrow n times to get the mv command again.

How can I keep just one ls command instead of n.

share|improve this question
up vote 11 down vote accepted

Setting the following environment variable:


Will prevent duplicate commands from being logged.

share|improve this answer
Thank you ,its worked for me. – user31985 Jan 17 '10 at 15:28

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.