history
history 命令可以用来显示曾执行过的命令,也可以根据显示的治疗来重新执行需要的命令
n 显示n个最近的记录
-a 添加记录
-r 读取记录,但不会添加内容记录
-w 覆盖原有的history 文件
-c 清除记录
-d<编号>[n] 删除指定n条记录
-n<文件> 读取指定文件
-r<文件> 读取文件但不记录
-w<文件> 覆盖原有文件
例1
复制代码代码如下:
[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
例2
复制代码代码如下:
[root@redhat ~]# ! -N #执行倒数第N条命令
[root@redhat ~]# !! #执行上一条命令
fc
fc 命令可以编辑曾今执行过的命令,并以批处理的形式让这些命令重新执行
-1 列出第一个指令和最后一个指令之间额度所有指令
-n 不显示编号
-r 反向排序
-e<文本编辑器> 指定文本编辑器编辑,默认Vi
-s<指令> 选择指令执行
例1
复制代码代码如下:
[root@redhat ~]# fc -l #查看执行过的命令,根history,很相似
348 eval echo "aaa" ls
349 eval echo "aaa";ls
350 exec ls
351 apt-get install mysql
352 apt-get install mysql-server
353 exit
354 expr 4%6
355 expr 4 % 6
356 expr 4<6
357 expr 4'<'6
358 expr 6 '+' 5
359 expr 6 '*' 5
360 expr 6 '>' 5
361 fc -l
362 man fc
363 fc --help
复制代码代码如下:
[root@redhat ~]# fc -s 358 #执行第358个命令
expr 6 '+' 5
11
复制代码代码如下:
[root@redhat ~]# fc 358 #编辑第358个命令
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 【中国音乐】盛中国《新疆之春》2004[FLAC+CUE]
- 群星《音你而来 第8期》[320K/MP3][44.64MB]
- 群星《音你而来 第8期》[FLAC/分轨][121.21MB]
- 群星《十二女声Ⅲ》[WAV/CUE/分轨][626.4MB]
- 陈百强.1993-离不开...纪念歌集2CD【华纳】【WAV+CUE】
- 于台烟.2003-爱自己【乾坤唱片】【WAV+CUE】
- 群星.2024-我们永远是我们电影原声带【乐禾发文化】【FLAC分轨】
- 【中国民乐】张维良《秋江夜泊》2004[FLAC+CUE]
- 明达年度发烧碟MasterSuperiorAudiophile2011[DSF]
- 明达年度发烧碟MasterSuperiorAudiophile2017[DSF]
- 翁立友.2008-恨孤单【大旗】【WAV+CUE】
- 群星.2009-Magic.Cover日粤精华3CD【环球】【WAV+CUE】
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]