The Shell’s History

The Shell’s History

The shell remembers the history of your last typed commands. It is what you see when you use the up and down keys in Bash.

There are plenty of ways to use this history! I will write some tips here that I know but don’t hesitate to add more in comments.

  • the ! tip: starting a line by ! followed by the first few letters of a previous command recalls it, very useful !
  • ! followed by a number recalls this command.
  • the !? tip: is somewhat similar but doesn’t only look at command starting with the following letters but containing them !
  • ‘#’ comments the commands but still records it. (if you have something to check while typing a long command)
  • of course the history command shows you the last commands ;)
  • [ctrl-r] put you in history mode
  • if you don’t like this feature, you can filter it with HISTIGNORE

example :

export HISTIGNORE="&:ls:\[bf\]g:exit"

suppresses duplicate commands, the simple invocation of ‘ls’ without any arguments, and the shell built-ins bg, fg, and exit:

And if you include the expression “[ t]*” in the HISTIGNORE string, you can suppress history recording at will for any given command just by starting with a space!

This entry was posted in BASh. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">