Finding Commands Quickly


Question: I was looking at a man page yesterday, but I can't remember the name of the command I was reading about and I didn't write it down. How do I get the man page back?

The command you used will most likely be stored in a file called .bash_history. By default, this file records the last 500 commands you typed at the shell prompt.

You can glimpse the history of your commands by typing history at the shell prompt, but the results will scroll by too quickly for you to be able to read every line.

Another way to view .bash_history is with a utility such as less. Type less .bash_history at the shell prompt, and the results will display one page at a time. To move forward a screen, press the spacebar; to move back a screen, press the b key; and to quit, press q.

Paging through .bash_history to find a command can be tedious. To save time, you can search through the file for keywords using grep, a powerful search utility.

Say you were reading a man page the day before, but cannot recall its name. To search for the command, type:

 history | grep man 

You will see a list of all the commands you typed that have the word man in them.

There are plenty of ways to use your command history. For other tips and tricks, see the next section.




The Red Hat Documentation Team - Official Red Hat Linux User's Guide
The Red Hat Documentation Team - Official Red Hat Linux User's Guide
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net