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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command to get Previous command list

Status
Not open for further replies.

ctau

IS-IT--Management
Feb 8, 2000
34
0
0
US
Does anyone know the command used to retrieve previous commands that you have used?  Also could this be put in a .profile?
 
You can access your history file by adding set -o vi to your .kshrc file if you are using the korn shell.  This can also be typed at the command line.  After this option is set you can hit the escape key and then the k key.  You should be able to access 128 of you previously used commands this way.  Hope this helps!
 
Thanks that does help a lot.  Is there anyway to change is so that all commands are saved instead of just the 128 most recent.
 
You can specify how many commands are kept by using the HISTSIZE environment variable.&nbsp;&nbsp;The default for this variable is 128.&nbsp;&nbsp;You can set this variable in your .profile if you wish to change it, I'm not sure how to make it unlimited.&nbsp;&nbsp;Your .sh_history file stores these commands and could grow VERY large in a short period of time, you might want to keep an eye on this.&nbsp;&nbsp;Hope this helps. <p>Christopher Devenny<br><a href=mailto:c_devenny@yahoo.com>c_devenny@yahoo.com</a><br><a href= > </a><br>
 
You need to do this to use the command history in your Korn Shell:<br><br>edit your .profile and add the line<br><br>export ENV=~/.kshrc<br><br>edit your .kshrc (or create it if it doesn't exist yet) and add the line<br><br>set -o vi<br><br>When you re-login you can use the command recall functions first pressing the Escape key and then you can use<br><br>k to go to the previous line<br>j to go to the next line if it exists<br>h or backspace go to left<br>l or space to go right<br>i to insert at cursor position<br>dd to delete a line<br>Enter to reexecute<br><br>etc, these are the vi editing keys if you know.<br><br>If you put set -o vi in your .profile your lose this functionality in your child shells.<br><br>I hope it works<br>Ramon Barrios Lascar RamonBarrios AT uol.com.co
 
Also note that the .sh_history file will record all commands entered for all sessions on that user so that if any other people log on with the same user then their commands are will be recorded as well. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
I fogot to add, if you do have to use a group user you can declare your own history file using the HISTFILE variable. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top