1752815 Members
5933 Online
108789 Solutions
New Discussion юеВ

Re: enable History file

 
SOLVED
Go to solution
HDgio
Regular Advisor

enable History file

Hello to all
Someone knows like qualifying history file on a shell sh?
16 REPLIES 16
Pete Randall
Outstanding Contributor
Solution

Re: enable History file

In your profile, put something similar to this:

HISTFILE=/tmp/.sh_history.$(whoami)
export HISTFILE

Then enable it with "set -o vi"



Pete

Pete
Graham Cameron_1
Honored Contributor

Re: enable History file

This comes up quite often.
See

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=59366

Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Madhu Sudhan_1
Respected Contributor

Re: enable History file

The real Bourne Shell doesn't support history.

-Madhu
Think Positive
Stefan Farrelly
Honored Contributor

Re: enable History file

We use this;

HISTFILE=${HOME}/.history_files/.hist.`who am i|awk '{print $1}'`.$$.`date +%d%m%y.%H%M`
HISTSIZE=1000

in our .profile so we get a unique history file for each user by date for auditing purposes.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Pete Randall
Outstanding Contributor

Re: enable History file

?

Pete
Bill Hassell
Honored Contributor

Re: enable History file

Yes, the Bourne shell does not have a history feature. However, no one uses the Bourne shell because it is located in a very obscure location (/usr/old/bin/sh). Unfortunately, the HP POSIX shell is called sh too so it is easy to be confused by the name. The file /usr/bin/sh (and the archived library file /sbin/sh) are both POSIX shells (like ksh) and have a history file available.

To enable the history file, the env variable HISTFILE (and optionally HISTSIZE) must be set at login. This is best done in /etc/profile for 'normal' logins.


Bill Hassell, sysadmin
Madhu Sudhan_1
Respected Contributor

Re: enable History file

Thanks Bill. I couldn't explain it so clear.

Thanks,
Madhu
Think Positive
Geoff Wild
Honored Contributor

Re: enable History file

Here's a cool thing to do if you have multiple admins who su to root.

In root's .profile, add:

# Set up logging
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
date >>$HISTFILE
export HISTFILE
HISTSIZE=500
export HISTSIZE

This creates a seperate .sh_history file for each admin - for example, mine is:

.sh_history_gwild

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
HDgio
Regular Advisor

Re: enable History file

After what I've configured the .profile for ebnable a history file, how I can recall a line command ?

es:fc -l
134 pwd
135 ls
136 ll

for recall the ls command?
!ls