Operating System - HP-UX
1748241 Members
3737 Online
108759 Solutions
New Discussion юеВ

Re: how to edit the already used command and running that again

 
SOLVED
Go to solution
senthil_kumar_1
Super Advisor

how to edit the already used command and running that again

Hi

I can get my previous commands (command history) by pressing "esc+k".

But i can't edit that commmand.

Since i want to change some option and run that command.

pls explain me on what are the keys are used to edit the previously entered commands.

what are the methods you are following?
13 REPLIES 13
Ron Irving
Trusted Contributor

Re: how to edit the already used command and running that again

it works the same as the 'vi' editor. Once you 'esc-k', you can roll the cursor right with the 'l' key, and replace a charachter with 'r', and such.

HTH
Should have been an astronaut.
Steven E. Protter
Exalted Contributor

Re: how to edit the already used command and running that again

Shalom,

.x from vi will run a command after editing.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: how to edit the already used command and running that again

Hi:

It is assumed that you are running either the standard HP-UX Poxix shell ('/usr/bin/sh' or '/sbin/sh') or the Korn shell ('/usr/bin/ksh').

Then, in your ${HOME)/.profile make sure you have:

export HISTFILE=${HOME}/.sh_history
export HISTSIZE=100

Add these lines; logout and login again. Now do 'esc+k' then 'j' or 'k' to move backward and forward exactly as you would navigate a file with 'vi'. You can now use any 'vi' command to edit the line and hit the ESC key and the ENTER key to execute the modified line.

Regards!

...JRF...
Bijeesh
Respected Contributor

Re: how to edit the already used command and running that again

Hi
Command line editting is possible and is like vi editting.

1)move to the end of the line ... $
2)delete the characters .... x
3)Insert any other characters .. i
4)replace one character ..... r

You can do more if you are interested in learning vi editor.
Kris Knigga
Advisor

Re: how to edit the already used command and running that again

In command mode (you are automatically in command mode right after you've found the command you want to edit using Esc-k), you can even just type v to edit your command in a full vi instance. Just :wq to run it.
Avinash20
Honored Contributor

Re: how to edit the already used command and running that again

http://docs.hp.com/en/A1700-90014/ch04s11.html
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
senthil_kumar_1
Super Advisor

Re: how to edit the already used command and running that again

Hi

I added the following line in ".profile" of user's home directory

export HISTFILE=$HOME/.sh_history
export HISTORY=100

then i log out from that user.

then i logged in.

but i am not able to get the command history.

pls help me
T G Manikandan
Honored Contributor

Re: how to edit the already used command and running that again

now the History is enabled. From now on , whatever you type on command prompt will be stored with history.

type couple of commands like

$ls
$pwd

now

$history
Suraj K Sankari
Honored Contributor

Re: how to edit the already used command and running that again

HI,
You can edit command in command prompt as you edit in "vi"

Here you need to export HISTFILE not HISTORY

export HISTFILE=$HOME/.sh_history
export HISTFILE=100

Suraj