LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   .bash_history file is not current to output of history (https://www.linuxquestions.org/questions/linux-newbie-8/bash_history-file-is-not-current-to-output-of-history-793680/)

mattseanbachman 03-06-2010 04:30 PM

.bash_history file is not current to output of history
 
Having an issue with my .bash_history file. It's certainly not a crisis, but it's been bothering me ever since I noticed it.

Say I look at my bash history by just getting onto a terminal and doing
Code:

history
This is totally different from what comes up when I do a
Code:

vim /home/toor/.bash_history

I remember typing both sets of commands, but the output from the command 'history' is much more current than is the file that it's presumably reading from to present it to me via my terminal!

So what gives? My OS is Linux Mint; as far as I can recall, the two files are synced on Fedora, but it's been a while since I've used that.

If anyone's dealt with, noticed this problem I'd appreciate any tips for getting them synchronized with one another.

-Matt

TB0ne 03-06-2010 05:10 PM

Quote:

Originally Posted by mattseanbachman (Post 3888589)
Having an issue with my .bash_history file. It's certainly not a crisis, but it's been bothering me ever since I noticed it.

Say I look at my bash history by just getting onto a terminal and doing
Code:

history
This is totally different from what comes up when I do a
Code:

vim /home/toor/.bash_history

I remember typing both sets of commands, but the output from the command 'history' is much more current than is the file that it's presumably reading from to present it to me via my terminal!

So what gives? My OS is Linux Mint; as far as I can recall, the two files are synced on Fedora, but it's been a while since I've used that.

If anyone's dealt with, noticed this problem I'd appreciate any tips for getting them synchronized with one another.

-Matt

Exit your current shell, and the history file gets updated.

ArfaSmif 03-06-2010 09:33 PM

There are several parameters which affect your bash history. Have a look at these (and there are more too):-

HISTCONTROL=ignorespace
HISTFILE=/home/username/.bash_history
HISTFILESIZE=2000
HISTSIZE=2000

and do a "man bash" to see what each parameter refers to.

Tinkster 03-06-2010 10:31 PM

On top of the two previous suggestions you may find
Code:

shopt -s histappend
export PROMPT_COMMAND='history -a'

added to your ~/.bashrc rather useful ...


Cheers,
Tink

mattseanbachman 03-07-2010 01:25 AM

Sincere thanks for the help!


All times are GMT -5. The time now is 11:49 AM.