Le Mon, Aug 24, 2026 at 06:15:20AM -0400, anonymous a écrit :
> -------------------------------------------------------
> Date: Mon 24 Aug 2026 10:15:13 AM UTC By: Anonymous
> HISTFILESIZE is only applied on shell launch and shell exit, when calling
> `history -w` or `history -a` the file is not truncated at all. Meanwhile the
> reference clearly states "The history file is also truncated to this size
> after writing it when a shell exits or by the history builtin. "
>
> Example: (.bashrc is empty)
> ```
> [ilya@arch ~]$ history
> 1 1
> 2 2
> 3 3
> 4 4
> 5 5
> 6 history
> [ilya@arch ~]$ HISTFILESIZE=5
> [ilya@arch ~]$ history -w
> [ilya@arch ~]$ cat .bash_history
> 1
> 2
> 3
> 4
> 5
> history
> HISTFILESIZE=5
> history -w
> ```
> Observe that `history -w` wrote the whole history. Same with `history -a`
> Now we exit and reopen the shell and see that `exit` respected HISTFILESIZE
> ```
> [ilya@arch ~]$ cat .bash_history
> history
> HISTFILESIZE=5
> history -w
> cat .bash_history
> exit
> ```
There seem to be alwost two alternatives:
1 ) export HISTFILESIZE
2 ) run command history -w as:
HISTFILESIZE=5 history -w
--
Félix Hauri - <[email protected]> - http://www.f-hauri.ch