My typical work flow at the bash prompt consists in typing commands and retrieving them using the Ctrl+R "literal" mechanism.

I have noticed over possibly the last couple of years that there are times where a command randomly disappears from the bash history.

Say I type and execute successfully the following:

$ command A arg1 arg2
$ command B arg3
$ command C arg4

… and type Ctrl+R arg1 — e.g. I get a "failed-reverse-i-search `arg1' ..." error.

Something of interest is that if I follow up with a:

$ history | less

... command A is indeed NOT the history... but I have a line that starts with an asterisk in "column 0" of the history ­— column 0 means the column just left of the column where the commands logged in the history start ­— followed by a blank line.

Has anyone seen anything like this?

This is on a debian/linux stable (buster) running bash 5.0.3.

  • IIRC it happens when the line in history is edited, but I can't remember what settings control that etc
    – ilkkachu
    Feb 23, 2020 at 23:27

2 Answers 2


Has anyone seen anything like this?

Yes. To reproduce:

  1. Run echo foo.
  2. Run echo bar.
  3. so echo foo appears (or Ctrl+rfoo, so echo foo appears, then hold to get to the end of the line).
  4. Hold Backspace, turn echo foo into an empty line, do not execute.
  5. , so echo bar appears.
  6. Enter to execute echo bar again.

Then history will print an empty entry where you might expect echo foo. It will be marked with * meaning this entry has been edited.

Check the revert-all-at-newline readline variable (see man 3 readline).

  • Temporary setting: run bind 'set revert-all-at-newline On' in Bash.
  • Persistent setting for new Bash instances: place set revert-all-at-newline On in /etc/inputrc or ~/.inputrc.
  • Excellent. Used your scenario to re-create. Since I don't use cursor arrows or Backspace preferring CTRL+U CTRL+W CTRL+A CTRL+E etc… it's not obvious how I manage to run into this ­— on rare occasions… must be a scenario where perhaps I mistype my search argument and clear the command-line before I retry a CTRL+R…? But now I know about this readline feature I'll just set revert-all-at-newline variable to On (bind -V shows it's currently off in my profile) to be on the 'safe side'… and this should take care of the problem. Must count myself as very lucky indeed I got an informed answer so fast! Feb 24, 2020 at 0:04

If there is a space before your command, it will not be logged.

  • No. In this particular case the command is a compilation which was retrieved a few dozen times during the session, with the appearance on the screen of the command followed by a CTRL+A to get out of command-retrieval mode and move the cursor to the beginning of the command and then followed by <Enter>. Feb 23, 2020 at 23:08
  • Just tested in my setup. If I enter <space+command> (something I do not use frequently) the command is not logged in the history list (as expected) but I do not get an empty line in the history (with an asterisk in the column between the command number and the commands proper) either: if I do command A + command B (prefixed by a space) + command C there is not trace in the history list of my having entered anything in between command A and command C. Seems like a description of what exactly these empty lines with an asterisk are might help? Feb 23, 2020 at 23:21

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.