I am using the ksh shell. I am not getting any impact of these following commands. It is executing without any error but it is not giving the proper results.


Use the Up arrow to view the previous command and press enter to execute it.

Type !! and press Enter from the command line.

Type !-1 and press Enter from the command line.

Press Control+P will display the previous command, press Enter to execute it.

Basically I am not to do anything other than basic history command.

  • So what happens when you do this? What did you expect to happen? What is not working as expected? Your question is incomprehensible. – Gilles 'SO- stop being evil' Feb 8 '13 at 22:50
  • For the information of all.. I am new to UNIX and Linux. I dont know why this question has been treated as not real.. Strange.. – viswad0Dine Feb 13 '13 at 16:41
  • Look below the question: “It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete (…) and cannot be reasonably answered in its current form”. Edit your question to answer my clarification requests, and we can reopen it. – Gilles 'SO- stop being evil' Feb 13 '13 at 17:36
  • Why is it difficult to tell what is being asked here? just because you guys don't know enough about the topic and maybe should not try to reply then? – Florian Heigl Jan 24 '18 at 10:51

Did you find these commands here: how to find result of last command? Do you realize that is not a correct answer? Do you realize it's talking about bash, not ksh?

To answer the question you asked:

Which version of ksh do you have? You can find out by pressing Ctrl+V or EscCtrl+V, or by running echo $KSH_VERSION.

Why do you think these actions will work? !! and !-1 are for bash, zsh, and csh, not for ksh.

For Ctrl+P to do anything, ensure you are using emacs editing mode by running set -o emacs.

For making the up arrow key work, there are several Google results. Try e.g. this one Make Arrow and Delete keys work in Korn Shell, which says how to do it using the alias command.

| improve this answer | |
  • Thanks for this.. I was new to linux and unix world. so I was struggling to articulate this question.. Now I am learning the Linux... Now I have understood these things.. Nw it seems simple.. anyhow thanks for your answer @mikel – viswad0Dine Mar 21 '13 at 11:44

Basically, that depends on the particular ksh implementation. For pdksh, for example, the history is enabled by default and is not stored in a file. For some UNIX ksh implementation it requires HISTFILE to be set to enable history. You may try setting it, or check your particular ksh implementation's manual.

Also, depending on the implementation you will or will not be able to use up arrow and other fancy ways to access previous commands. Sometimes you will only have emacs or vi mode and will be able to scroll through history with respective editor's commands.

And just to add, HISTTIMEFORMAT looks more like a bash extension…

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.