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?


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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