How to Search the UNIX History File
The Unix history list contains a record of the commands that you have issued at a command prompt. Each user has his own history list. The list is printed to the screen in chronological order when the command "history" is issued. The actual history file has a different name depending on the version of Unix and command shell being used. If you are using the bash shell in Linux it is called ".bash_history" and is stored in the user's home directory.
Instructions
-
-
1
Open a terminal window. The terminal window will be found on your desktop or in the "System Tools" or "Utilities" section of the main menu, depending on what version of Unix you are using.
-
2
Type the command "history" to see a complete history of the commands you have used.
-
-
3
Type the command "history | grep <command_name>" to search the history file for a particular command. Replace "<command_name>" with the complete command or a portion of the command. For example, if you were searching for the command "top," you would type "history | grep top."
-
4
Type the command "fc -l 20" to list the last 20 commands you used.
-
5
Type the command "fc -l 100 120" to show the commands between command 100 and command 120 in the history file.
-
6
Type the command "fc -l <command_name>" to list all the commands used since the last time you used the command "<command_name>". For example, type "fc -l top" to list all the commands used since the last time you used the "top" command.
-
1
References
- Photo Credit it worker image by kuhar from Fotolia.com