Operating System - HP-UX
1833777 Members
2053 Online
110063 Solutions
New Discussion

Re: Question about shell commands

 
SOLVED
Go to solution

Question about shell commands

Hi all,
I have a very little question about shell commanding:
I found, that I can use some commands from the command history by using esc+k. Now I'm searching for a command, and then I have to type very often k,k,k,k... . So what I'm looking for is, to give the first two or three digits from the command, and then to find it faster. How can I do that?
And how can I increase the history length?

Thank you for your reply!

Daniel :-)
6 REPLIES 6
Addie Wevers
Occasional Contributor

Re: Question about shell commands

Hi Daniel,
Esc+k is very usefull. After this you can use vi-commands to search in your command history.
So, type '/' and a part of the command you are looking for, and press enter. When you need the next command, just type 'n' (next).
The history can be increased by setting the variable HISTSIZE in your .profile. For example, 'export HISTSIZE=5000'.
Rainer_1
Honored Contributor
Solution

Re: Question about shell commands

searching a command can be done with the / character

[ESC]K
/

increase history with setting the variable HISTZISE ie:

HISTSIZE=500 ; export HISTSIZE

insert this into /etc/profile or $HOME/.profile
(the default for HISTSIZE is 128)

For more information see

man sh-posix
Tommy Palo
Trusted Contributor

Re: Question about shell commands

Almost everything said here.
You can also use [ESC]z and /.
If you know your 'vi' you also know that when typing 'n', a ? (question mark) reverses the search direction. Good if you passed by the command you were looking for.
Keep it simple
Dan Hetzel
Honored Contributor

Re: Question about shell commands

Hi Daniel,

Nearly everything has been said before but another useful key to know is 'N'

If after having searched for a command containing a string, typed a few times 'n' for the preceeding occurence, typing 'N' will back to the previous one. Useful if you're typing too fast like most of us ;-)

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Stefan Schulz
Honored Contributor

Re: Question about shell commands

There is also another funktion (at least in ksh). You can use r with the beginning of the command you want. For example your last commands look like:

>lpstat -t
>cd somewhere
>vi something
>man command

After this you can recall the lpstat command with:

>r lps

But you have to use the beginning of the command (as far as i know).

Hope this helps also.

Regards

Stefan
No Mouse found. System halted. Press Mousebutton to continue.

Re: Question about shell commands

Thank you all.
Your comments are very helpful.

Best regards
Daniel :-)