How do I add a date and time to my bash shell history in linux?

                  If  this  variable  is  set and not null, its value is used as a
                  format string for strftime(3) to print the time stamp associated
                  with  each  history  entry displayed by the history builtin.  If
                  this variable is set, time stamps are  written  to  the  history
                  file  so they may be preserved across shell sessions.  This uses
                  the history comment character  to  distinguish  timestamps  from
                  other history lines.

    Set this variable to a date and time format in your bash shell environment file.
    export HISTTIMEFORMAT="%d/%m/%y %T "

    Before setting the variable history shows the following.

    $ history
        1  who
        2  uptime
        3  history

    After setting the variable.

    $ history
        1  14/04/20 08:47:24 who
        2  14/04/20 08:47:26 uptime
        3  14/04/20 08:47:30 history

© Lightnetics 2022