history命令的用法及参数

history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
参数:
   n :数字,要列出最近的若干命令列表
  -c :将目前的shell中的所有history内容全部消除
  -a :将目前新增的history指令新增入histfiles中,若没有加 histfiles ,则预设写入 ~/.bash_history
  -r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中
  -w :将目前的 history 记忆内容写入 histfiles

重复执历史特定指令

[root@keystone ~]# history 10 # 列出最后10条执行的命令
[root@keystone ~]# !988 # 执行第988条指令
[root@keystone ~]# !! # 执行最后一条指令
[root@keystone ~]# history -c # 清除所有的指令记录
Read more »