linux history -c bash,Linux 命令(command) history

1、使用语法:history (选项) (参数)

1)选项

-c:清空当前历史命令;

-a:将历史命令缓冲区中命令写入历史命令文件中;

-r:将历史命令文件中的命令读入当前历史命令缓冲区;

-w:将当前历史命令缓冲区命令写入历史命令文件中。

2)参数

n:打印最近的n条历史命令。

3)常用实例:

显示最近10条历史命令

[root@linux ~]# history 10

69 ls -al

70 cd linux

71 ls -al

72 cd ..

73 ls -al

74 ssh root@192.168.31.55

75 ssh root@192.168.31.11

76 git

77 python

78 history 10

清空历史命令

[root@linux ~]# history -c

将当前或所有历史命令缓冲区中命令立即写入文件(~/.bash_history),也可以自己指定文件。

[root@linux ~]# history -w 或 [root@linux ~]# history -w histfiles

[root@linux ~]# history -a 或 [root@linux ~]# history -a histfiles

可以将之前保存的历史命令的文件读到缓冲区

[root@linux ~]# history -r 或 [root@linux ~]# history -r histfiles

2.执行历史记录中的命令

1) !number:执行历史命令记录中第number条命令。

2) !commandstr:在历史记录中搜索最近一条与commandstr相匹配的命令执行。

3) !!:执行历史命令记录中的最后一条。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值