Operating System - HP-UX
1843944 Members
2515 Online
110226 Solutions
New Discussion

Recalling last typed commands

 
Ruben Cardenal_2
Occasional Contributor

Recalling last typed commands

Hi people,

With sh, the way of recalling the last typed commands is pressing Esc and then with '+' and '-' search for the desired command. But is there any way of having sh acting like bash? This is, the list of typed commands through the arrow (up and down) keys.

TIA
6 REPLIES 6
H.Merijn Brand (procura
Honored Contributor

Re: Recalling last typed commands

Bash is available for HP-UX (http://hpux.connect.org.uk/hppd/hpux/Shells/bash-2.05b/), why not use it?

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
John Dvorchak
Honored Contributor

Re: Recalling last typed commands

Yes Esc k will scroll backwards and j will go forward after you have gone back a little. Also while we're at it
Esc / some_string will search for that string in your history.

Esc Esc will auto complete a file/directory name.

You have to have three environment variables set to get the most out of the history:

export HISTFILE=/home/.sh_history
export HISTSIZE=1000 (for 1000 lines)
export EDITOR=vi

Have fun and good luck.
If it has wheels or a skirt, you can't afford it.
Ruben Cardenal_2
Occasional Contributor

Re: Recalling last typed commands

procua, I can't install bash on the machine :(

Jhon, that was already knew :P
T G Manikandan
Honored Contributor
Colin Topliss
Esteemed Contributor

Re: Recalling last typed commands

That would possibly depend on what you are using to log into your UNIX system with.

If you are just telnetting in from a PC, then no.
If you are SSH'ing in, then unlikely.
If you're on the console, then no.
If you are using Exceed, then you *may* be able to remap your arrow keys to do an 'h' or 'j' - the problem would be that you would still need to do the inital before attempting to use the mapped keys.

Personally I think it is more trouble than its worth though.
CCIL
Frequent Advisor

Re: Recalling last typed commands

Hi If you have HP-Unix , which is hving default shell as posix , you can recall the previuos command using the keystroke esc k, set the shell variable HISTSIZE & HISTFILE, HISTSIZE will be the number , that many number of command you can recall , HISTFILE=~/.sh_history, where all the command will be stored , history file
Amit Vichare