Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Command Line Editing - Please advise!

Occasional Contributor

Command Line Editing - Please advise!




I'm pretty new to the HP-UX. I cannot make the backspace and edit if something goes wrong. I understand there is no Bash in HP-UX, however is there any options available.


Thank you


Respected Contributor

Re: Command Line Editing - Please advise!



The bash shell is not available in HP-UX by default. However you can install it and get the bash functionality.


It is available in folloing link.


If you need the bash shell only for backspace function, then you set the terminal as below.

if you want it to be permanently, edit your .profile file.


#stty erase ^?




Occasional Contributor

Re: Command Line Editing - Please advise!

Thanks for your quick reply. I did tried as said above, but throwing some errory. Please advise. Thanks in advance. 


# stty erase^?
unknown mode: erase^?

Honored Contributor Honored Contributor

Re: Command Line Editing - Please advise!

There's a space between the 'erase' and the '^?'.  To get the '^?' character just hit the backspace key after entering 'stty erase '.  The '^?' should echo to the screen.  Then you can hit enter.




# stty erase <hit backspace key here> 



Acclaimed Contributor Acclaimed Contributor

Re: Command Line Editing - Please advise!

Default command line editing is just like using vi.

As a hp-ux (or unix in general) user to should know or learn some basics.

Hope this helps!


There are only 10 types of people in the world -
those who understand binary, and those who don't.


No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Acclaimed Contributor Acclaimed Contributor

Re: Command Line Editing - stty

>#stty erase ^?


This depends on what your terminal emulator sends.  I want the backspace key and control-H to do the same thing so I have to use: stty erase ^h


>To get the '^?' character


You can also type this as two separate chars or the DEL char.


>Default command line editing is just like using vi.


You can confirm this in a real shell by doing:

$ set -o

And check if vi or emacs is set.

Honored Contributor Honored Contributor

Re: Command Line Editing - Please advise!

[ Edited ]

I'll take a guess that you are using PuTTY as your terminal emulator. This very popular (and free) program has one very annoying default: the backspace key is mappopen the ed to the DEL (delete) key, *not* the backspace key. So when you use the backspace key, you'll see ^? on the screen which is the shell's way of showing you this invisible character. To change your emulator to use the backspace key (for PuTTY), open the Configuration window and select:


Terminal -> Keyboard


and change the Backspace key from Control-? to Control-H (which is the backspace key. Be sure to save this new setting. 


Another possibility is that your TERM value has been set to "vt100" and unfortunately, the terminfo database defined the ERASE key as Delete. This can be seen with the command: untic vt100, and look for the capname "kbs" which refers to the keyboard backspace character. For (IMHO) sane settings, look at untic hp and you'll see kbs=\b which means that the backspace (action to erase the previous character) is backspace and not 177 which is the Delete key.


To fix the default TERM value, add this line to your profile:


stty erase"^H"


Set your .profile and alsoterminal emulator.


Why is backspace mapped to the Delete key? Most likely the original designers for PuTTY and terminfo settings were OpenVMS or DEC OS users where the erasing of a character meant pressing the Delete key. Just a guess...


Once you are able edit your lines with the backspace key, the next (non-intuitive) change is to enable command line recall. This requires several changes:


1. Your shell must be the POSIX shell (/usr/bin/sh or /sbin/sh) or ksh. Note that the Bourne shell is obscured in the /usr/old/bin directory -- don't use it.


2. Edit your .profile to add these lines:


export HISTFILE=$HOME/.sh_history

export HISTSIZE=5000

export EDITOR=/usr/bin/vi


3. Create the history file:


touch $HOME/.sh_history


4. Logout and login again. Type a command like ls. Then type ESC k (the Escape key followed by the letter k). You should see the ls command echoed on the line ready to edit. Verify that the history can be shown by typing the command: history


There are several command line recall/edit features. Read the man pages for sh-posix (shortcut: man fc) or man ksh and look for Command Line Editing and vi Editing.