2
what is the command to see the previously executed command that was run on the command line ?
2
what is the command to see the previously executed command that was run on the command line ?
12
use the history
command.
history -1
will display only the last command. Otherwise, history
will list the last 16 commands (for plain ksh
, but this may differ with other korn-compatible shells).
You can also use the fc
builtin command if you are using plain ksh
(command options are described in the man page).
0
According to this post, you can use the Up Arrow key once you add the following lines to the bottom of your .kshrc file in your $HOME directory:
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
0
It depends on your shell. If you want to run the last command, in bash for example, you can type !!
.
See this page for more info.
EDIT
Oh well, now I noticed that you had tagged your post ksh. Sorry about that. I'll leave this answer here anyway. Maybe it helps someone someday :)
history lists the last 500 commands for me. (But I'm on OS X.) – Eric Wilson – 2010-06-24T18:12:52.503
then, you are probably using
bash
and notksh
. – tonio – 2010-06-24T18:22:22.070I did the test on MacOSX 10.5.8:
ksh
's history displays only 16 entries, as osx'sman ksh
says (search for "16" in the man page).bash
's history displays the whole$HISTFILE
. (for you, 500 as you probably have$HISTFILESIZE
set to 500. – tonio – 2010-06-24T18:29:01.0671And regarding bash's history command:
alias h='history $((LINES - 1))'
is good to view recent history without completely destroying the scrollback. – None – 2010-06-26T11:48:36.680