0

Recently, line numbers have started to appear in my .bash_history file. Where before, for example I might have had just

rm -rf *

I now have entries like

#1565909296
rm -rf *

How do I prevent those line limbers (or timestamps, or whatever they are) from accumulating in my .bash_history file?


These numbers seem to have nothing to do with any of my settings (and in any case started to appear without any adjustments to theses settings having been made):

$ grep -i 'hist' .bash* .profile
.bash_profile:export HISTCONTROL=ignorespace:ignoredups
.bash_profile:#export HISTCONTROL=ignoreboth:erasedups
.bash_profile:#export HISTCONTROL=ignoreboth:ignorespace:ignoredups
.bash_profile:export HISTSIZE=10000
.bash_profile:export HISTFILESIZE=500000
.bash_profile:SHELL_SESSION_HISTORY=0
.bash_profile:export HISTTIMEFORMAT='%y-%m-%d-%T   '
1

Update: The recent edit you've made to you question shows the following line being in your .bash_profile file:

export HISTTIMEFORMAT='%y-%m-%d-%T   '

Remove this line to stop the timestamp from being added to the ~/.bash_history file.


Original Answer:

As HISTTIMEFORMAT is not set by default, up to an including macOS Mojave, you'll need to check one of the following files to see where it was added:

  • /etc/bashrc
  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
  • ~/.bashrc

Removing the line that has HISTTIMEFORMAT from the file that has it will stop the timestamp from being added to the ~/.bash_history file.

Note: The dot files mentioned in the $HOME directory are hidden and some may not exist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .