Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrow up (like doskey), how to 1

Status
Not open for further replies.

Periko

Programmer
Feb 24, 2003
134
BE
Hello,

How can I get a list of my previous commands i typed in ? Like in doskey in the early years, with arrow up, we can take the previous command, etc... etc....

Any idea what the possibilities are with this ? Like listing, deleting this list, etc... ??

Greets...
Pedro...
 
it depends on the Shell you are using: if you use "bash" or "shell" it works with "arrow up". When you use "ksh" first excute: set -o vi, after this you will be able with "ESC & K" to went back to the last commands used.

hope this helps

regards
 
by the way you can check your Shell with: echo $SHELL
 
OK, thank you guys

So it is /bin/sh

I log in as SU with the passwd. How can i get a list of the commands i typed in before, and how can i delete them, that is realy my question.

Thx in advance...
Pedro...
 
I don't think standard bourne (sh) supports history. You'll need to change to ksh or bash to do this. Someone will correct me if I'm wrong....
 
Hi Ken,

yes, you can, so far i got yet, but read my previous. I suppose it is the file .bash_history or sth like that, that you can edit and clear ? Is that the only way ? Someone ?????

Pedro...
 
Yes. in ksh it's .sh_history. Usually this will cycle the commands based on $HISTSIZE or a similar variable to set the number of commands stored in the file. .sh_history isn't easily read with usual editors or cat, but can be cleared with touch .sh_history if that's what you want to do.
 
Hi,

if you want to 'read' the commands entered previously: 'history' command works in csh, bash, ksh.
Alternatively : 'strings .sh_history' (or whatever your history file is called)
And I agree with Ken that there is no history for sh .

regards
 
Thx Hoinz,

That a lot of information. Have you any idea if there is any option to disable this feature, that any commands are written to this history file ? if so, how to do ?

Thx...
Pedro...
 
Hi,
I don't think that there is an easy way to avoid history.
And for security reasons there shouldn't be ...
regards
 
I'm not sure about disabling, and personally I don't want to try this, but I'm sure that if you really don't want to log your previous commands, set the $HISTFILE variable to 0 (not sure if this is allowed), or 1.

I would personally really recommend against this though....
 
Why are you trying to delete or modify your command history ??? Are you hacking a server you shouldn't be, or doing something dodgy ?

Anyone who is doing what they are supposed to does not mind their history being logged !!!
 
a hint by the way.
you also can use the command: history : to list your history and : history -c to clear it.

regards

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top