[root@linux ~]# history [n] [root@linux ~]# history [-c] [root@linux ~]# history [-raw] histfiles 参数: n :数字,意思是『要列出最近的 n 笔命令列表』的意思! -c :将目前的 shell 中的所有 history 内容全部消除 -a :将目前新增的 history 指令新增入 histfiles 中,若没有加 histfiles ,则预设写入 ~/.bash_history -r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中; -w :将目前的 history 记忆内容写入 histfiles 中! 范例: 范例一:列出目前内存内的所有 history 记忆 [root@linux ~]# history # 前面省略 1017 man bash 1018 ll 1019 history 1020 history # 列出的信息当中,共分两栏,第一栏为该指令在这个 shell 当中的代码, # 另一个则是指令本身的内容喔!至于会秀出几笔指令记录,则与 HISTSIZE 有关! 范例二:列出目前最近的 3 笔资料 [root@linux ~]# history 3 1019 history 1020 history 1021 history 3 范例三:立刻将目前的资料写入 histfile 当中 [root@linux ~]# history -w # 在预设的情况下,会将历史纪录写入 ~/.bash_history 当中! [root@linux ~]# echo $HISTSIZE 1000 我们可以利用相关的功能来帮我们执行命令呢!举例来说啰: [root@linux ~]# !number [root@linux ~]# !command [root@linux ~]# !! 参数: number :执行第几笔指令的意思; command :由最近的指令向前搜寻『指令串开头为 command』的那个指令,并执行; !! :就是执行上一个指令(相当于按↑按键后,按 Enter) 范例: [root@linux ~]# history 66 man rm 67 alias 68 man history 69 history [root@linux ~]# !66 <==执行第 66 笔指令 [root@linux ~]# !! <==执行上一个指令,本例中亦即 !66 [root@linux ~]# !al <==执行最近以 al 为开头的指令(上头列出的第 67 个)
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|