linux(十四)history- 复用输入历史

history

history 这个命令用来管理你在shell中曾经输入过的命令
history -n
显示最近n条命令
history -c
清空当前shell中history的内容

history -raw

-r :将histfiles(存储history命令的文件)中的内容读到当前shell中
-a: 将当前新增的history命令新增到histfiles
-w:将当前的history记忆内容写入histfiles中(覆盖)

history常用方式

!number

执行history记录中第number条指令

!command

执行history中以command开头的命令(从后向前找)

!!
执行上一条命令

示例


[wang@localhost ~]$ !210         # 我的第210条命令是 `ls`
ls
\          Desktop    Music     spf13-vim.sh  vmware-tools-distrib
aliyun.sh  Documents  Pictures  Templates
crontab2   Downloads  Public    Videos
[wang@localhost ~]$ !l             #以l开头的最后输入的命令是`ls`
ls
\          Desktop    Music     spf13-vim.sh  vmware-tools-distrib
aliyun.sh  Documents  Pictures  Templates
crontab2   Downloads  Public    Videos
[wang@localhost ~]$ !!             # 上一条命令是ls
ls
\          Desktop    Music     spf13-vim.sh  vmware-tools-distrib
aliyun.sh  Documents  Pictures  Templates
crontab2   Downloads  Public    Videos
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容