添加Linux history命令时间标记

  1. 切到/etc/profile.d/目录下
  2. 编辑一个以"sh"结尾的文件
  3. 输入 export HISTTIMEFORMAT=" %F %T" (其中%F代表日期,%T代表时间)
  4. source这个文件
[root@lb-test-01 data]# cd /etc/profile.d/
[root@lb-test-01 profile.d]# vim env.sh
[root@lb-test-01 profile.d]# cat env.sh
export HISTTIMEFORMAT="%F %T"
[root@lb-test-01 profile.d]# source env.sh
[root@lb-test-01 profile.d]# history 377 2022-07-19 18:02:40cd /etc/profile.d/ 378 2022-07-19 18:03:16vim env.sh 379 2022-07-19 18:03:25cat env.sh 380 2022-07-19 18:06:37source env.sh 381 2022-07-19 18:06:41history

 

  调用历史命令,可直接使用"!"+历史编号

[root@lb-test-01 profile.d]# !382
echo "test"
test

 

posted @ 2022-07-20 09:11  技术小白学学学  阅读(165)  评论(0)    收藏  举报