Add timestamp to history

History usually only gives the command number and the command. This will add a timestamp to the history file. Note: this will only put the correct timestamp on commands used after the export is done. You may want to put this in your .bashrc
Sample Output
3619  2009-05-12 13:24:09 ls
3619  2009-05-12 13:26:32 pwd
3619  2009-05-12 13:28:48 cat README

2009-05-12 14:36:42

What Others Think

Thanks, I really like this.
anzan · 645 weeks and 6 days ago
Must replace ? by "
aurium · 645 weeks and 6 days ago
Hmm, that's strange, I know I put quotes there.
fritz_monroe · 645 weeks and 6 days ago
worth a 10 up, definitely!!
icetek · 645 weeks and 5 days ago
Great one.. thanks for this from your hidden treasury..
mohan43u · 645 weeks and 3 days ago
Nice one. Older commands in history do get correct-looking timestamps on my machines (Debian Lenny bash 3.2.39 and Mac OS X 10.5.6 bash 3.2.17).
gthb · 645 weeks and 2 days ago
fritz- you can edit your command to replace the questions-marks by quotes... I'll vote up when its fixed.
Iftah · 645 weeks and 1 day ago
All fixed. This is my first command submitted, I didn't know they were editable.
fritz_monroe · 645 weeks and 1 day ago
Wonderful. Goes into my ~/.bashrc straight away.
sunny256 · 644 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: