当前位置: 首页>>技术教程>>正文


如何永远改变历史规模?

,

问题描述

Ubuntu中历史记录的默认大小是1000,但它太小了。我想将它改为10000,所以我追加

export HISTSIZE=10000
export HISEFILESIZE=10000

.profile和’source’吧

source .profile

然后我跑了

echo $HISTSIZE
echo $HISTFILESIZE

两者都显示了1000但我重新启动计算机它去了’default’。为什么不起作用?

最佳解决思路

我尝试了同样的事情,只是发现偷偷摸摸的Ubuntu默认情况下在~/.bashrc中设置这些变量,对于非登录shell(例如只打开终端窗口)执行而不是~/.profile。在~/.bashrc中更改这些行为我修复了它:

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

次佳解决思路

From the Bash Reference Manual

HISTSIZE 
    The maximum number of commands to remember on the history list.

    If the value is 0, 
       **commands are not saved** in the history list. 

    Numeric values less than zero result in 
       every command being saved on the history list (there is no limit). 

因此,对于无限历史列表,make:HISTSIZE =(某些数字小于0)

HISTFILESIZE 
    The maximum number of lines contained in the history file. 

    When this variable is assigned a value, 
        the history file is truncated, if necessary, 
        to contain no more than that number of lines 
        by removing the oldest entries. 

        The history file is also truncated to this size after 
        writing it when a shell exits. 

    If the value is 0, 
        **the history file is truncated to zero size.** 

    Non-numeric values and numeric values less than zero 
        inhibit truncation. 

因此,对于无限的.bash_history历史文件,make:HISTFILESIZE =(某些数字小于0)

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2349.html,未经允许,请勿转载。