history
补充说明
语法
history(选项)(参数)选项
-c:清空当前历史命令;
-a:将历史命令缓冲区中命令写入历史命令文件中;
-r:将历史命令文件中的命令读入当前历史命令缓冲区;
-w:将当前历史命令缓冲区命令写入历史命令文件中。参数
实例
Last updated
history(选项)(参数)-c:清空当前历史命令;
-a:将历史命令缓冲区中命令写入历史命令文件中;
-r:将历史命令文件中的命令读入当前历史命令缓冲区;
-w:将当前历史命令缓冲区命令写入历史命令文件中。Last updated
[root@localhost ~]# history 10
92 ls
93 cd ..
94 ls
95 exit
96 ls -a
97 cd .ssh/
98 ls
99 cat known_hosts
100 exit
101 history 10[root@localhost ~]# history 3
15 2017-08-26 11:44:35 root history 3
16 2017-08-26 11:44:37 root history n
17 2017-08-26 11:44:40 root history 3[root@localhost ~]# history -chistory -cw
`~/.bash_history`: 保存历史命令
`/etc/profile` -> HISSIZE: 历史命令保存数量
推荐添加 h -> history, hsi -> history|grep 别名
`!n`: 执行第 n 条历史命令
`!xxx`: 执行最后一条 xxx 开头的命令