keifer
keifer

Reputation: 155

Display commands history based on time and date

is it possible to display(or set to display) the format of command "history" to have the date in it? As by default the format is numbering, time, and the command.

My purpose is to grab/find back/display the commands based on the time and date, while now it only have the time in it. Thanks.

Upvotes: 1

Views: 4262

Answers (1)

hari
hari

Reputation: 9733

http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/ - This explains.

Basically,

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

Before issuing command above

1995  cd
1996  pwd
1997  history 
1998  echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
1999  exit
2000  history
2001  cd
2002  pwd
2003  grep
2004  history

And after:

 1995  07/08/11 22:39:33 cd
 1996  07/08/11 22:39:33 pwd
 1997  07/08/11 22:39:33 history 
 1998  07/08/11 22:39:33 echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
 1999  07/08/11 22:39:33 exit
 2000  07/08/11 22:39:43 history
 2001  07/08/11 22:39:45 cd
 2002  07/08/11 22:39:46 pwd
 2003  07/08/11 22:39:50 grep
 2004  07/08/11 22:39:53 history

Upvotes: 1

Related Questions