首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"bash --noprofile --norc“摧毁.bash_history

"bash --noprofile --norc“摧毁.bash_history
EN

Ask Ubuntu用户
提问于 2022-12-13 04:12:08
回答 1查看 61关注 0票数 1

虽然我的HISTFILESIZEHISTSIZE大于500,但在我进入"norc“外壳后,bash历史就被销毁了。如何通过各种shell类型保存历史数据?

下面是一个实际的例子。

代码语言:javascript
复制
// on the normal shell (bash)
/mnt/c/pg$ wc ~/.bash_history
  876  1997 19855 /home/user/.bash_history

/mnt/c/pg$ logout

PS > bash --noprofile --norc

// on the norc shell
bash-4.4$ wc ~/.bash_history
  847  1947 19406 /home/user/.bash_history
// -> notice that .bash_history is trimmed to the default 500 lines. This is the problem.

bash-4.4$ exit

// again on the normal shell
PS > bash

/mnt/c/pg$ wc ~/.bash_history
  848  1948 19439 /home/user/.bash_history
// -> once I enter to a norc shell, it affects the entire shell experiences

这是我的.bashrc和.profile的一部分

代码语言:javascript
复制
// .bashrc

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=100000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

// .. 
代码语言:javascript
复制
// .profile

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=100000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

// .. 
EN

回答 1

Ask Ubuntu用户

发布于 2022-12-16 04:22:29

使用空的HISTFILE运行它,所以shell不会尝试更新默认文件:

代码语言:javascript
复制
HISTFILE= bash --noprofile --norc
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1445324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档