Korn Shell bascis – how to access command history

April 10, 2010


As part of my job I now have to work with ksh (Korn Shell) scripts under AIX servers.  If you are looking for Korn, a “nu metal” style band, then you are in the wrong place :)

I had previously not written any shell scripts, so is here basics that I am learning at the moment.

To access command history

Usually in bash, or probably other shell (even on windows too) a command history can be accessed simply by pressing <UP> and <DOWN> keys. This is not the case with ksh. In fact, your command line is more like in vi “insert mode”. That is, you can type commands, but if you press up or down, you wont access command history, and pressing <LEFT> or <RIGHT> wont move your cursor, instead it will produce more or less random unexpected results.

You can quit this “insert” mode by pressing quit (more or less like in vi and vim). Then you can use regular keys ‘j’ and ‘k’ to move up or down in history. ‘h’ and ‘l’ can be used to move your carret and edit your current command. ‘a’ (append) and ‘i’ insert, as well as all other standard vi / vim text editing commands are useful.

Refer to vi cheat sheet for more details on vi commands.

P.s. yes, on the servers i am working there are is no vim, only vi.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: