Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

If I perform a sequence of commands like:

$ ls
$ grep abc file.txt

and then use the up arrow key to get the previous one, the terminal will show the last cmd (which is the grep here)

But if I do something like this:

$ ls
$   grep abc file.txt

where grep is preceded by spaces, pressing up gives ls, not grep.

Why is this?

share|improve this question
Follow-up: Why does bash have a HISTCONTROL=ignorespace option? – Gilles Feb 19 '14 at 23:39

1 Answer 1

up vote 18 down vote accepted

man bash:


A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand for ignorespace and ignoredups.

share|improve this answer
and HISTCONTROL is set to ignoreboth in the default ~/.bashrc provided by debian at least. – Stéphane Chazelas Feb 19 '14 at 15:15
What is the use case of ignorespace? – Ciro Santilli 六四事件 法轮功 包卓轩 Sep 28 at 14:30

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.