Little Girl's Mostly Linux Blog

BashHistory

Bash history

This page was last updated on July 18, 2009.

  • Auto-complete a command that you’ve made before:
    1. Press the Ctrl and r keys at the same time.
    2. Start typing the command. It will suggest the most recent match.
    3. Continue typing the command until you have the match you want.
    4. Press the Enter key.
  • Check Bash history of a command:
    • Type this command in a terminal window, replacing foo with the name of the command you’d like to check:
    • grep -a foo .bash_history
  • Clear Bash history:
    • Type this command in a terminal window:
    • history -c
  • Display the last 500 commands you typed:
    • Type this command in a terminal window:
    • history
  • Select one of the last 500 commands you typed by number:
    • Type this command in a terminal window, replacing n with the number of the command from the Bash history:
    • !n

      Each command you enter changes the numbering of the last 500 commands, so check the list before choosing a number.

  • Re-enter the last command
    • Type this command in a terminal window:
    • !!
  • Run the *most recent* command that starts with specific letters
    • Type this command in a terminal window, replacing foo with the first few letters of the command you’re looking for:
    • !foo
  • Search Bash history
    • Use your up and down arrow keys to scroll through the Bash history.
    • Or type this command im a terminal window, replacing foo with the command you’re looking for:
    • history | grep foo



Obligatory Happy Ending

And they all lived happily ever after. The end.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: