[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的更多相关文章

  1. 历史命令history

    历史命令在用户注销之后会保存在用户家目录下的-/.bash_history中 history #查看系统中实时缓存的历史命令,与.bash_history中的内容并不完全相同 history -c # ...

  2. linux查看历史命令history

    在linux下,我们有可能需要查看最近执行过的命令(历史命令),我们可以进行如下操作: # 显示使用过的所有历史命令 $ history # 显示最近使用的5个命令 $ history 5 我们可以通 ...

  3. linux显示历史命令history

    history history//显示历史命令

  4. 查看历史命令 history

    生产上有文件被清空了,想查查是谁操作的? 通过history查看历史命令: $history |more 也可以通过文件查看历史命令: $vi ~/.bash_history 只显示历史命令,像查一查 ...

  5. 记录用户操作历史命令history

    我们知道可以使用history命令,查看自己的操作记录,但如果你是root用户,如何查看其它用户的操作记录呢?   其实history命令只是把当前用户目录下的~/.bash_History文件内容列 ...

  6. linux 查看历史命令 history命令

    1.history命令 "history"命令就是历史记录.它显示了在终端中所执行过的所有命令的历史. history //显示终端执行过的命令 history 10 //显示最近 ...

  7. linux 历史命令用法(转)

    许多使用过Linux一段时间的人通过一些基础操作已经能够把Linux各方面基本玩转,但是如果没有经过系统学习的话就容易缺乏一些实战技巧.这系列文章介绍一些关于bash的能够提高效率的技巧,主要是关于历 ...

  8. 历史命令~/.bash_history,查看所有别名alias,命令执行顺序,命令行常用快捷键,输入输出重定向,wc统计字节单词行数

    历史命令大小:/etc/profile中字段HISTSIZE=1000 历史命令保存文件:~/.bash_history history -c 清空历史命令 history -w 把历史命令写入~/. ...

  9. linux常用命令 history命令

    历史命令 history [选项] [历史命令保存文件] 选项 '-c' 清空历史命令 '-w' 把缓存中的历史命令写入历史命令保存文件~/.bash_history [root@ssgao1987 ...

  10. 自学Linux Shell5.2-shell内建命令history alias

    点击返回 自学Linux命令行与Shell脚本之路 5.2-shell内建命令history alias 外部命令:有时称为文件系统命令,是存在于bash shell之外的程序,通常位于/bin./u ...

随机推荐

  1. 页面动态table动态合并table

    function hebingRows(col, atrrb) { var trs = $("table tbody tr"); var rows = 1; for (var i ...

  2. C++ 全局变量、局部变量、静态全局变量、静态局部变量的区别

    全局变量.局部变量.静态全局变量.静态局部变量的区别 C++变量根据定义的位置的不同的生命周期,具有不同的作用域,作用域可分为6种:全局作用域,局部作用域,语句作用域,类作用域,命名空间作用域和文件作 ...

  3. Python体验(08)-图形界面之工具栏和状态栏

    # coding=utf-8 import wx # 导入必须的Python包 class MenuForm(wx.Frame): def OnQuit(self,event): self.Close ...

  4. autoit小贴士

    如何防止程序重复运行? #include <Misc.au3>_Singleton("test") 如何删除脚本程序自身? ;删除脚本程序自身 Run(@ComSpec ...

  5. java httpclient cookie

    BasicCookieStore cookieStore = new BasicCookieStore();BasicClientCookie cookie = new BasicClientCook ...

  6. SetTimer 与 回调函数

    在控制台应用程序中,SetTimer的函数原型为: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // ti ...

  7. oracle修改字段长度

    alter table 表名 modify (字段名 字段类型长度);alter table cachemsg modify (callernum varchar(40));

  8. RequireJS 加载 easyui

    requireJS 可以让js加载起来比较优雅,像java里import一样.有了这个,我们可以创建自己的 js控件库,在需要时,页面中只引入 requireJS,然后通过代码方式引入需要用到的控件, ...

  9. 使用yum安装应用程序时候,报错:[Errno 14] PYCURL ERROR 7 - "Failed to connect to 2001:da8:8000:6023::230: 网络不可达"

    使用yum安装应用程序时候,报错:[Errno 14] PYCURL ERROR 7 - "Failed to connect to 2001:da8:8000:6023::230: 网络不 ...

  10. python模块之subprocess

    可以执行shell命令的相关模块和函数有: os.system os.spawn* os.popen*          --废弃 popen2.*           --废弃 commands.* ...