"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says

D02:-/home/user1/temp> /job
ksh: /job: not found.
D02:-/home/user1/temp>

previously it used to fetch all the commands which had job in it..
for example subjob, endjob, joblist etc...

may I know where am I going wrong..?

I use putty to access unix aix.. Thanks

The problem seems to be your command line editor setting. "/" is only available in the so-called "vi-mode" of ksh, which is invoked by

set -o vi

You can enter this either on the command line (valid only for this invocation of the ksh) or in your "~/.kshrc" (automatically read by all invocations of ksh by this user account).

There are other modes of command line editing, which might or may not suit you: "gmacs" ("set -o gmacs") invokes a gmacs-style command line editor, and "emacs" ("set -o emacs"), which switches the command line to behave like the EMACS editor.

There is ample documentation of the benefits for all of these possibilities, my favoured vi-style is described here, for example.

I hope this helps.

bakunin

1 Like

Hi Bakunin, thanks for quick reply..

I think my VI command line editing mode is already on.. as I can use all the other vi commands on the command mode except for "/"

I tried "set -o vi" on command prompt as well as .profile..
but still not able to search history of commands.. :frowning:
Don't know where am I going wrong..

Make sure that the user in question is actually create a ~/.sh_history file. If this file doesn't exist then there is no history to search.

What happens if you type history at the command prompt?

@ross.mather
Thanks for reply..

when I type history...

D02:-/home/user1/data> history
2301 lsd
2302 lsrt
.
.
.
.2316 history

I get the history of typed commands, so what u r saying is not the problem.. ( i.e. .sh_history file is created.. )

OK I see what you've done, when you use / on the command line like that, AIX thinks you are trying to run a command called /job. What you need to do if you are in vi mode is to press Escape and then do /job:

You may need to press n a couple of times to get over the commands you've already entered as /job on the command line.

I this case it might be that your shell is configured not to write any command history. Per default the command history is saved to a file named "~/.sh_history", which can be viewed/edited like any other ordinary text file. You can also try the commands "last" and "history" to view the contents of the history file. It might be that you have either configured no history to be written or configured a history file which isn't writeable somehow or something similar. How to configure the history file is in the man page of ksh ("man ksh").

Another possibility is that the "ESC" character is not working somehow, because you said in your first post:

It seems that you simply entered "/job" instead of "<ESC>/job". Find out if your ESC key is working and make sure it has the correct key mapping.

You shouldn't set this in your "~/.profile", but in your "~/.kshrc". The difference is a subtly yet important one: the profile is read every time you log in, the .kshrc is read every time you start a shell. Of course, when you log in you start a shell too, so there is no difference in this case. But if you start another shell instance (for instance by issuing "ksh" on the command line) your "~/.kshrc" will be executed while your "~/.profile" will not.

The correct way to set the ksh environment is to put everything which should be set in every ksh-instance into "~/.kshrc" and to write "ENV=~/.kshrc ; export ENV" as the last line in your "~/.profile".

I hope this helps.

bakunin

@ Ross, Bakunin

Thanks a ton man.... I see where I was going wrong.. tried with Escape key.. and it worked.... I forgot using the escape key.. :wink: