星空网 > 软件开发 > 操作系统

历史命令:history

[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 个)




原标题:历史命令:history

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Depo:https://www.goluckyvip.com/tag/1162.html
出口限制:https://www.goluckyvip.com/tag/11620.html
外贸信用证:https://www.goluckyvip.com/tag/11621.html
中美磋商:https://www.goluckyvip.com/tag/11623.html
垂直电商:https://www.goluckyvip.com/tag/11624.html
跨境运营难题:https://www.goluckyvip.com/tag/11626.html
2024年如何找到在TikTok上发帖的最佳时间:https://www.kjdsnews.com/a/1836408.html
旅游互联时代的商机与挑战(详细剖析行业现状与前景):https://www.vstour.cn/a/363175.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流