是否可以显示(或设置为显示)命令"history“的格式以在其中包含日期?默认情况下,格式为编号、时间和命令。
我的目的是根据时间和日期抓取/查找/显示命令,而现在它只有时间。谢谢。
发布于 2011-08-08 13:42:42
http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/ -这解释了。
基本上,
$ echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile在发出上述命令之前
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在此之后:
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 historyhttps://stackoverflow.com/questions/6977984
复制相似问题