[NTLUG:Discuss] keeping your bash history.

MadHat madhat at unspecific.com
Thu Aug 28 09:14:40 CDT 2003


On Thu, 2003-08-28 at 00:51, Paul Ingendorf wrote:
> Do I keep reading this wrong? Is he not looking for a way to save those
> history files not obliterate them?

It's the first line that was throwing us off.

OK, so each time bash is run it loads the .bash_history into memory. 
When you exit bash, it writes out the .bash_history

If you have multiple bash shells running, then the last one closed will
overwrite any changes made before with its version of the history file
which is what it loaded plus any command executed with it.

So, to be able to do what you want is possible, but I am not sure there
is an easy way.  On exit, before writing the file, the existing
.bash_history fine would have to be read in and compared to what is
about to be written.  All duplicates sections removed and trimmed down
to under a specific size, add the new section at the end and then
written.  I would make .bash_history a FIFO (named pipe) and put a
script on the other end to do all this, but I am a masochist.

I am sticking with possible, but I don't know an easy way.

> 
> -----Original Message-----
> From: discuss-bounces at ntlug.org [mailto:discuss-bounces at ntlug.org]On
> Behalf Of Thomas Cameron
> Sent: Wednesday, August 27, 2003 4:49 PM
> To: NTLUG Discussion List
> Subject: Re: [NTLUG:Discuss] keeping your bash history.
> 
> 
> export HISTFILE=/dev/null
> --
> Thomas Cameron, RHCE, CNE, MCSE, MCT
> Cameron Technical Services, Inc.
> http://www.camerontech.com/
> (512) 454-3200
> ----- Original Message -----
> From: "Richard Geoffrion" <ntlug at rain4us.net>
> To: <discuss at ntlug.org>
> Sent: Monday, August 25, 2003 3:18 PM
> Subject: [NTLUG:Discuss] keeping your bash history.
> 
> 
> > To keep your bash history from being recorded during a session, one can
> > issue the command  'unset HISTFILE' before exiting.
> >
> > HOWEVER, when one has MULTIPLE terminal windows opened up, only that last
> > one to close seems to save its HISTFILE information into the bash history.
> >
> > Is there a way to force a write to the bash history as one exits each
> shell
> > so that the entire history of all bash sessions are recorded?   Could this
> > be automated in the logout/logoff process?
> >
> > --
> > Richard
> >
> >
> 
> 
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
-- 
MadHat at Unspecific.com
`But I don't want to go among mad people,' Alice remarked.
`Oh, you can't help that,' said the Cat: `we're all mad here...'
   -- Lewis Carroll - _Alice's_Adventures_in_Wonderland_




More information about the Discuss mailing list