To see a list of commands you have used you can use the history command. You can also use common editor commands to navigate quickly to specific commands in the history.
If you want to 'record' a set of commands and their outputs use the script command, which writes to a file in the current directory (called typescript by default).
The history command is a Korn/Bash shell built-in command that lists previous commands entered. The Korn shell saves commands that you entered to a command history file, usually named $HOME/.sh_history or $HOME/.bash_history. Using this command saves time when you need to repeat a previous command.
By default, the Korn shell saves the text of the last 128 commands for nonroot users and 512 commands for the root user. The history file size (specified by the HISTSIZE environment variable) is not limited, although a very large history file size can cause the Korn shell to start slowly.
In bash under Linux you can use the cursor keys to navigate your history.
In ksh you can navigate using standard vi keystrokes using:
set -o vi
To use cursor keys in ksh you can use this...
set -o emacs
alias __A=$(print '\0020') # ^P = up = previous command
alias __B=$(print '\0016') # ^N = down = next command
alias __C=$(print '\0006') # ^F = right = forward a character
alias __D=$(print '\0002') # ^B = left = back a character
alias __H=$(print '\0001') # ^A = home = beginning of line
Add them to .kshrc or your .profile as necessary.To view the history:
history
To run the command numbered 992 in the snippet shown above...
!992
Each line has a position number. To delete an entry from the history based on that position number...
history -d 992
To save any modifications to the history file...
history -w
script
Script started, file is typescript<run your commands here>
exit
Script done, file is typescript