| View previous topic :: View next topic |
| Author |
Message |
Jarli n00b

Joined: 22 Mar 2012 Posts: 8
|
Posted: Wed Nov 14, 2012 3:54 pm Post subject: Command History |
|
|
Is there anyway to determine when a command was run on Gentoo, through a terminal session?
I know the 'history' command shows the list of commands, but I would like to see if there is a time stamp. |
|
| Back to top |
|
 |
eccerr0r Advocate

Joined: 01 Jul 2004 Posts: 3000 Location: USA
|
Posted: Wed Nov 14, 2012 4:43 pm Post subject: |
|
|
This link got me
http: //larsmichelsen.com/open-source/bash-timestamp-in-bash-history/
This assumes that you're using bash. _________________ Core-i7-2700K@4.1GHz/8GB RAM/180GB SSD/Intel HD3000 graphics
What the heck am I advocating? |
|
| Back to top |
|
 |
tomk Administrator


Joined: 23 Sep 2003 Posts: 7098 Location: Sat in front of my computer
|
Posted: Wed Nov 14, 2012 4:50 pm Post subject: |
|
|
Moved from Gentoo Chat to Portage & Programming as it's not about Gentoo itself.
As the link that eccerr0r posted shows you need to set HISTTIMEFORMAT, assuming you're using bash. Obviously this will only show you the timestamp after you've set it, for commands before that it will just use the current time which is then cached. _________________ Search | Read | Answer | Report | Strip |
|
| Back to top |
|
 |
khayyam Veteran


Joined: 07 Jun 2012 Posts: 1268
|
Posted: Wed Nov 14, 2012 7:10 pm Post subject: |
|
|
Jarli ...
zsh timestamps (with 'shopt extended_history' set) ... the history file can then be parsed with the following:
| Code: | | # perl -lne 'm#: (\d+):\d+;(.+)# && printf "%s :: %s\n",scalar localtime $1,$2' $HISTFILE |
I'm not sure if bash timestamps are constructed in a similar manner but is should be parsable none the less with a similar oneliner.
best ... khay |
|
| Back to top |
|
 |
|