How to find date wise history of commands being fired [duplicate]

断了今生、忘了曾经 提交于 2019-12-29 01:38:29

问题


How can I make the history command display the date and time information in addition to the command line?


回答1:


The history of executed commands is stored by your shell. Try adding something like this to you ~/.bashrc

export HISTTIMEFORMAT="%m/%d - %H:%M:%S: "

It will change the HISTTIMEFORMAT variable and bash will store a timestamp in its history accordingly. Then your history will look like this

487  08/16 - 16:12:01: cd Downloads
488  08/16 - 16:12:04: ls -a
489  08/16 - 16:12:37: cat README | less
490  08/16 - 16:12:58: pkg-config --list-all | grep webkit
491  08/16 - 16:13:04: history

Available identifiers are

%d - Day
%m - Month
%y - Year
%T - Time
%H - Hours
%M - Minutes
%S - Seconds


来源:https://stackoverflow.com/questions/11987761/how-to-find-date-wise-history-of-commands-being-fired

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!