Monday, April 27, 2009

How to find a command that you used before?

I use this all the time because I can't seem to remember anything these days.
There is a command called "history" that will print out the last 500 (I think) commands that were entered on the command line.

Just type as follows:

> history

You will see a list like this:

737 cd
738 history > eric_history.txt
739 more eric_history.txt
740 wc eric_history.txt
741 history
742 ls
743 more eric_history.txt
744 more eric_history.txt
745 ls
746 who
747 fi
748 date
749 ls
750 history

The cool thing is when you see the command you need you can run it by typing ! followed by the number. For example, say I wanted to run line 743 above.
I would type:

> !743 ( This is very handy.)

From time to time I backup my history file using something like line 738 above.

Commands used in this post: history

No comments: