17

There are many bash guides that include adding lines such as HISTTIMEFORMAT='%d/%m/%y %T ' or HISTTIMEFORMAT="%F %T " to ~/.bashrc or /etc/bash.bashrc.

There's always a space before the final quote. E.g. it's never HISTTIMEFORMAT='%d/%m/%y %T'.

Why is this?

19

If the trailing space is not included in HISTTIMEFORMAT, then you won't have a space between the timestamp and the command. Here are some examples:

HISTTIMEFORMAT="%F %T: "

This results in:

33916  2014-12-18 11:03:08: echo foo

Without the space:

HISTTIMEFORMAT="%F %T:"
33916  2014-12-18 11:04:11:echo foo
| improve this answer | |
  • Thanks. I didn't think that, since I had expected there to be a space between each timestamp and command automatically. – EmmaV Dec 18 '14 at 17:13
  • 3
    Quote from the manual: "No intervening blank is printed between the formatted time stamp and the history line." – Benjamin W. Jul 20 '17 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.