Celeb Glow
news | March 28, 2026

How to ignore duplicates in bash history [duplicate]

Centixels-MacBook-Pro:~ Centixel$ /* some command */
Centixels-MacBook-Pro:~ Centixel$ ./a.out
Centixels-MacBook-Pro:~ Centixel$ ./a.out
Centixels-MacBook-Pro:~ Centixel$ ./a.out
Centixels-MacBook-Pro:~ Centixel$ 

I want to be able to access /* some command */ in two upkey presses, rather than 4 or N upkey presses. Is this possible to implement in settings? I hate having to upkey a million times through repeat commands to access a previous command.

If this is a repeat question, please refer me, I was not sure how to ask the question. Thank you in advance for your help.

Centixels-MacBook-Pro:~ Centixel$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

Edit:

# .bashrc
# User specific aliases and functions
. .alias
alias ducks='du -cks * | sort -rn | head -15'
# Source global definitions
if [ -f /etc/bashrc ]; then . /etc/bashrc
fi
PATH=$PATH:/home/username/bin:/usr/local/homebrew
export PATH
export HISTCONTROL=ignoreboth:erasedups

This is my edited .bashrc file (in my home directory), and the changes seem to not have been enacted, I have restarted my terminal as well.

1

1 Answer

Add this to your .bashrc file:

export HISTCONTROL=ignoredups

According to bash manpage:

A value of ignoredups causes lines matching the previous history entry to not be saved.

3