From: J G Miller on
On Sun, 18 Apr 2010 22:00:30 -0400, David W. Hodgins wrote:

> In ram, for each bash session. From man bash ...

Yes, that makes sense. But can you explain this?

I have a terminal emulation (urxvt) window running with bash.

I do a history command and see the command I have recently
used. All is as expected.

In that terminal window, I fire up another urxvt with bash
as the shell.

I then do a history command and expect to see no commands,
since I have not issued any commands in that newly spawned
shell.

However the history command lists 1000 commands which I
was executing in a terminal window yesterday.

This does not make sense from the perspective of, a new
bash shell with no commands issues and therefore should
not have a history.




>
> On startup, the history is initialized from the file named
> by the variable HISTFILE (default ~/.bash_history). The file
> named by the value of HISTFILE is truncated, if necessary,
> to contain no more than the number of lines specified by the
> value of HIST‐ FILESIZE. When the history file is read, lines
> beginning with the history comment character followed
> immediately by a digit are interpreted as timestamps for the
> preced‐ ing history line. These timestamps are optionally
> displayed depending on the value of the HISTTIMEFORMAT
> variable. When an interactive shell exits, the last $HISTSIZE
> lines are copied from the history list to $HISTFILE. If the
> histappend shell option is enabled (see the description of
> shopt under SHELL BUILTIN COMMANDS below), the lines are
> appended to the history file, otherwise the history file is
> overwritten.
>
> Regards, Dave Hodgins

From: Bit Twister on
On Mon, 19 Apr 2010 14:14:21 +0200, J G Miller wrote:
> On Sun, 18 Apr 2010 22:00:30 -0400, David W. Hodgins wrote:
>
>> In ram, for each bash session. From man bash ...
>
> Yes, that makes sense. But can you explain this?
>
> I have a terminal emulation (urxvt) window running with bash.
>
> I do a history command and see the command I have recently
> used. All is as expected.
>
> In that terminal window, I fire up another urxvt with bash
> as the shell.
>
> I then do a history command and expect to see no commands,
> since I have not issued any commands in that newly spawned
> shell.
>
> However the history command lists 1000 commands which I
> was executing in a terminal window yesterday.
>
> This does not make sense from the perspective of, a new
> bash shell with no commands issues and therefore should
> not have a history.

Each new session starts out with current history file contents as history.

As indicated up thread, current session history is written to history
file upon session log out.

According to your description, there would be no history for any
session.
From: unruh on
On 2010-04-19, ynotssor <ynotssor(a)invalid.org> wrote:
> "unruh" <unruh(a)wormhole.physics.ubc.ca> wrote in message
> news:slrnhsn9pm.odi.unruh(a)wormhole.physics.ubc.ca...
>>
>> I am wondering where the bash history is kept-- the one which !
>> selects. I know about .bash_history, but that is NOT necessarily what
>> the ! uses.
>
> Why do you say that? The "!" means "most recent" to that particular shell
> instance.
>
> Necessarily, a shell's history is kept in that process's memory and is saved
> to ~/.bash_history when the shell exits. That particular ~/.bash_history is
> not available to other concurrent shells.
>
> Each shell has its own history, initiated from the most recently saved
> ~/.bash_history and updated from its own command history. What would you
> suppose happens when the system crashes due to a non-UPS power failure when
> several shells are open in various windows, or remote logins exist such as
> ssh, rsh etc, none of which are mutually exclusive?


Thank you. That is the info I need, that each shell maintains its own
history initialised from .bash_history. As I said, there was no instance
of "slay unruh" in .bash_history, and as I recall that instance of bash
had been begun recently (that day) as an ssh session from a remote
machine. Thus it is highly unlikely that it was in memory for that
session. Of course you might say "it must have been, bash does not make up
history entries". And I cannot argue against that.
What I was really asking was if there was somewhere that I could search
the histories that were being saved to see if somewhere that command WAS
being saved ( other than .bash_history). The answer seems to be "no".


>
> Consult the man page for whatever shell you happen to be using to understand
> the details please, then attempt to understand what's stated in the context
> of your own unique usage.
>
> If ou can state the detailed context of your own problem then people can
> better assist you.
>
>
>
From: Moe Trin on
On Mon, 19 Apr 2010, in the Usenet newsgroups comp.os.linux.misc and
alt.os.linux.mandriva, in article
<slrnhsot70.o48.unruh(a)wormhole.physics.ubc.ca>, unruh wrote:

>What I was really asking was if there was somewhere that I could search
>the histories that were being saved to see if somewhere that command WAS
>being saved ( other than .bash_history). The answer seems to be "no".

[compton ~]$ help history
history: history [n] [ [-awrn] [filename]]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
the last N lines. Argument `-w' means to write out the current
history file; `-r' means to read it instead. Argument `-a' means
to append history lines from this session to the history file.
Argument `-n' means to read all history lines not already read
from the history file. If FILENAME is given, then use that file,
else if $HISTFILE has a value, use that, else use ~/.bash_history.
[compton ~]$

You need to that in each _running_ shell. In most cases, it will
likely come up with

[compton ~]$ history | grep slay
1433 history | grep slay
[compton ~]$

but if it's within $HISTSIZE of the last commands in "this" shell and/or
terminal, it will show as

[compton ~]$ history | grep slay
1121 whatis slay
1122 which slay
1123 whereis slay
1124 locate slay
1125 man slay
1167 history | grep slay
[compton ~]$

Old guy