1.

Solve : retrieve a previously entered command - Linux?

Answer»

I've attempted to determine how to retrieve a previously command . My experience is basically Windows/DOS command line using the arrow direction keys.. This saves a lot of extra typing...

Perhaps someone has an idea.....



linux/unix typically allows each user to retrieve their previously entered commands using the up arrow key, and unlike Windows, the history extends to previous logins.

Have you tried it?

Pressing the UP arrow will return to previous commands.

To return to a previously entered command, TYPE ctrl-r and then begin typing the command. This will finish the command for you as you type. If you can REMEMBER to use ctrl-r, it will become invaluable for repeating longer commands.

To find a specific command among many previous commands; pipe history through grep:
history|grep -i first few letters of command

Also you have the history command.

http://webtools.live2support.com/linux/history.php

I've tried the arrow keys.. no success... I forgot to mention that I'm
remote accessing the Linux server using SSH - ACTUALLY Secure CRT...

It must be SSH that's interfering... the arrow keys result in a wierd display..

e.g.

Last login: Sat Dec 13 17:31:04 2008 from 10.244.142.7
$ ls -l
total 0
$ ^[[A^[[A >>>> the result of using the up arrow key a couple of times..QUOTE from: BRIANH on December 13, 2008, 03:36:34 PM

I've tried the arrow keys.. no success... I forgot to mention that I'm
remote accessing the Linux server using SSH - actually Secure CRT...

It must be SSH that's interfering... the arrow keys result in a wierd display..

e.g.

Last login: Sat Dec 13 17:31:04 2008 from 10.244.142.7
$ ls -l
total 0
$ ^[[A^[[A >>>> the result of using the up arrow key a couple of times..


Maybe this will help...

Code: [Select]SecurerCRT is just a dumb terminal emulator. The command
history and recall features are part of your shell. ASSUMING your
shell is /usr/bin/sh or /usr/bin/ksh, add these lines to /etc/profile
(so all users will have this feature):

export HISTFILE=$HOME/.sh_history
export HISTLINES=2000
export EDITOR=/usr/bin/vi
set -o vi

Now login again and you'll see your command history. Useful commands:

history
history -20

history is an alias to fc -l and fc is a shell built-in command. man sh-posix
or man ksh. You can type r ### where ### is the line number of a
command line shown by history.

You can use ESC / to recall previous commands by searching for a string.
Use + or - to move up and down once you have recalled a command.


http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1160294

Just a thought: Is your local machine running Windows or Linux? You may need to get the key mappings right.

My local machine is running Windows (T42 laptop).. I thought about the key
mapping but I suspect its the remote machine which is the issue here...
Don't know ....Have you tried the history command, and the ESC / keys, and + and - ?
The history command works.. the esc / key COMBINATION, the + and - do not..

At this point, with the history command, I guess the best way to repeat a cmd in the history list is using the r # cmd...


Discussion

No Comment Found