linux history command

2019-04-17 07:55发布

问题:

If I type history command, I can view only 1000 lines. I want to view more than that. It will be nice If I can view all commands typed between certain dates or months.

Is this possible? If so, how to do this?

回答1:

You want to set the bash variables HISTSIZE and HISTFILESIZE in your .bashrc.

HISTSIZE determines how many comands are retained in history. HISTFILESIZE determines how many lines of history are stored in the file in which they are persisted, usually .bash_history.



回答2:

add some commands to .bash_logout to organize your history files

e.g.

today=`date +%y%m%d`
cp .bash_history >.bash_history_$today
echo >.bash_history  # to clear out file

However, one problem: .bash_logout doesn't seem to run in a lot of X-based environments. On a ssh account, such as with a virtual server, it works fine.



标签: linux shell