Skip to main content
9 events
when toggle format what by license comment
Jan 18, 2023 at 11:24 comment added Otheus @porg Nice additions! Thanks!
S Dec 15, 2022 at 11:34 history suggested porg CC BY-SA 4.0
Made clear that in ~/.bash_history timestamps are stored as Unix Epoch Timestamps and that the history tool shows them in your preferred format during runtime.
Dec 15, 2022 at 10:13 comment added porg Thanks! zsh (or only the oh-my-zsh variant that I use?) has a timestamped history in its default configuration, which I loved. This answer explained me how to get that in bash too. Thanks!
Dec 15, 2022 at 10:12 review Suggested edits
S Dec 15, 2022 at 11:34
Jul 24, 2015 at 13:02 comment added Otheus Elaborate on history -a?? The man page is a little misleading. It appends the current session history to the file designated by $HISTFILE. Subsequent calls will append the history generated since the last invocation (it doesn't overwrite the whole file over and over again)
Jul 24, 2015 at 13:02 comment added Otheus The #1435987168 in the history file is the timestamp! There are a couple of ways to convert that into user-friendly format, including: load the history file into bash with history -n _filename_ and then history. Or you can do something like this: perl -lane '{ /^#(\d+)$/&&print "#".localtime($1) or print;}' $HISTFILE to display the history with the timestamps. So it's probably that the timestamps are correct, but you have a locale or timezone problem?
Jul 24, 2015 at 8:02 comment added SunLynx Thanks for suggestions but I've tested above. Can you please elaborate more about history -a. Shell script is working fine but wrong time stamps. This is the one problem and another is one number after every command which starting with #. for e.g. #1435987168.
Jul 23, 2015 at 16:38 history edited Otheus CC BY-SA 3.0
Did not see mueh's answer, updated mine with OPs second question
Jul 23, 2015 at 15:18 history answered Otheus CC BY-SA 3.0