Linux Shell script command history _ Display Operation Time

What the user what the current command execution time

① Scripting
to create scripts

vim displayHisoperTime.sh

Add the script reads as follows:

if ! grep HISTTIMEFORMAT /etc/bashrc; then
    echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/bashrc
fi

Save and exit:wq

② run the script

chmod u+x displayHisoperTime.sh
./displayHisoperTime.sh
或者
bash displayHisoperTime.sh

③ script Description of content

#export HISTTIMEFORMAT 将此变量输出到环境变量中
#%F %T                 日期时间格式
#whoami                当前用户
export HISTTIMEFORMAT="%F %T `whoami` "
history

Before
Here Insert Picture Description
after:
Here Insert Picture Description

Published 976 original articles · won praise 151 · Views 250,000 +

Guess you like

Origin blog.csdn.net/weixin_40816738/article/details/104850860