Linux战地日记——历史命令

历史命令

历史命令存放在.~/.bash_history中,他在用户主目录下。

通过输入$ history可查询当前历史命令

[bestcoder@localhost test1]$ history
    1  history
    2  history -a
    3  history 
    4  pwd
    5  date
    6  cat test1
    7  cd test1
    8  history


通过-c选项可删除历史文件中的所有清单

[bestcoder@localhost ~]$ history
    1  history


执行历史命令

命令替换的方式之一,以“!”开头。

格式

 !!   重复上一条命令

!n   重复第n条命令

!-n  重新执行倒数第n条命令

!ca 重新执行以ca开头的命令

!?string?  重新执行最新的包含字符串string的历史命令

!#   到目前所输入的整个命令行

[bestcoder@localhost test1]$ !2
history -a
[bestcoder@localhost test1]$ !4
pwd
/home/bestcoder/test1
[bestcoder@localhost test1]$ !date
date
2015年 09月 09日 星期三 22:28:13 PDT


可通过$ HISTFILE="/home/test/.myhistory"指定存放历史命令的文件。

可通过$ HISTSIZE=600指定bash保存的历史命令。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值