添加Linux history命令时间标记
- 切到/etc/profile.d/目录下
- 编辑一个以"sh"结尾的文件
- 输入 export HISTTIMEFORMAT=" %F %T" (其中%F代表日期,%T代表时间)
- 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
活到老,学到老
浙公网安备 33010602011771号