UNIX Shell History
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).
History
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.
Navigation
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.History Management
To view the history:
history
991 ps -ef | grep tns 992 lsnrctl stat 993 exit 994 cat /etc/oratab
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
The -n option suppresses the command numbers when listing. The -r option reverses the order of the commands. If the -l option is given, the commands are listed on standard output. Otherwise, the editor given by ename is invoked on a file containing those commands. If ename is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set. If neither variable is set, is used. When editing is complete, the edited commands are echoed and executed.
In the second form, command is re-executed after each instance of pat is replaced by rep. A useful alias to use with this is ``r="fc -s"'', so that typing ``r cc'' runs the last command beginning with ``cc'' and typ‐ ing ``r'' re-executes the last command.
If the first form is used, the return value is 0 unless an invalid option is encountered or first or last specify history lines out of range. If the -e option is supplied, the return value is the value of the last command executed or failure if an error occurs with the temporary file of commands. If the second form is used, the return status is that of the command re-executed, unless cmd does not specify a valid history line, in which case fc returns failure.
Script
script
Script started, file is typescript<run your commands here>
exit
Script done, file is typescriptBibliography
https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/osmanagement/listing_prev_cmds.htmlhttps://www.ibm.com/docs/en/aix/7.2?topic=commands-listing-previously-entered-history-commandhttps://www.unix.com/unix-for-dummies-questions-and-answers/17565-ksh-how-make-up-arrow-recall-command-history.htmlhttps://askubuntu.com/questions/344593/how-to-delete-selected-results-from-bash-history