开源是一种精神,分享是一种美德!

history

相关命令:fc
history 命令可以用来显示曾执行过的命令,也可以根据显示的治疗来重新执行需要的命令

n 显示n个最近的记录
-a 添加记录
-r 读取记录,但不会添加内容记录
-w 覆盖原有的history 文件
-c 清除记录
-d<编号>[n] 删除指定n条记录
-n<文件> 读取指定文件
-r<文件> 读取文件但不记录
-w<文件> 覆盖原有文件
[root@redhat ~]# history        #查看所有执行过的命令
    1  ls
    2  pwd
    3  fc -l
    4  history 
	
[root@redhat ~]# history 2      #显示2条
    4  history 
    5  history 2
	
[root@redhat ~]# !4             #执行编号是4的命令,注意感叹号
history 
    1  ls
    2  pwd
    3  fc -l
    4  history 
    5  history 2
    6  history 
	
[root@redhat ~]# history -c    #清除历史记录

!$ 引用前一个命令的最后一个参数


[tank@localhost workspace]$ ls -all
总用量 1060
drwxrwxr-x. 15 tank tank    4096 8月   6 16:26 .
drwx------. 60 tank tank    4096 8月  15 16:13 ..
-rw-r--r--   1 root root    2466 7月  23 18:02 1.html
drwxr-xr-x   7 tank tank    4096 7月  17 03:02 ckeditor
drwxr-xr-x.  2 tank tank    4096 5月  29 00:08 database

[tank@localhost workspace]$ !$         #取得-all
-all
bash: -all: command not found



[root@redhat ~]# ! -N             #执行倒数第N条命令

[root@redhat ~]# !!               #执行上一条命令

评论(1)

    • 14567
      内容太多太杂,看不清
      [回复]

评论

名字:
验证码:
获取验证码
内容: