Thursday, March 28, 2013

Display Date And Time For Each Command

How do I display shell command history with date and time under UNIX or Linux operating systems?



If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character. Defining the environment variable as follows:



$ HISTTIMEFORMAT="%d/%m/%y %T "

OR



$ echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile

Where,

%d - Day

%m - Month

%y - Year

%T - Time

To see history type



$ history



No comments:

Post a Comment