Linux Mall - The Linux SuperStore!
Linux books, Linux CDs, Linux toys, you name it, they have it!

W W W . L I N U X D O T . O R G

Newbie's Linux Manual
The Command History
] [ Download*] [ Previous] [ Next] Home] [ Contents] [ Download*] [ Previous] [ Next] Homepage| The Last 5 Days| The Daily Linux News| The Linux Bits| Newbie's Linux Manual
The Best Linux Sites| Linux Book Reviews| A Windows Vendetta?
Diary of a Linux Newbie| Diary of an Open Source Newbie
The Linux Forum| Just For Fun Amazon - The World's Biggest Bookstore!
4.7 million books, CDs, videos, and DVDs available to buy! Webmaster| Manual's Copyright Terms
[
* In Linux enter: unzip nlm.zip
Up and Down

Press the up and down cursor keys to move through the commands you entered previously and hit Enter when you find the one you want.

Note

What you're actually looking at is the line-by-line contents of your ~/.bash_history file. All the commands you entered during a session will be appended to this file each time you log out.

A Little History Lesson
- 1 -

Enter the following commands one by one:

ls -a
ls -l
ls --color
history 4

See how that last command displayed the last 4 history entries:

  493  ls -a
  494  ls -l
  495  ls --color
  496  history 4

- 2 -

Enter:

!ls

...to re-enter the last command that that begun with ls (in this case ls --color). Note that !l would have worked just as well in this instance.

Note

Entering history on its own will display every entry in your command history. If the command you're looking for has scrolled out of view, just enter:

history | less

...then find what you're looking for, and press q to quit the less program.

Notice how every entry is assigned an ID number. To re-enter command 494, you would enter:

!494

One Final Clever Trick
Say you just entered:
find -name budget98.txt

...to find where in your current directory the budget98.txt is located.

To re-issue the above command, but this time replace the 98 with 99 (to look for budget99.txt), enter:

^98^99

Clever, yes?

[
* In Linux enter: unzip nlm.zip
© MM Linuxdot.org |