linux查看执行过的命令行,在Linux命令终端中查看和编辑曾执行过的命令 – LINUX笔记 – CFEI.NET...
今天我們來講講linux的知識,積累的這些知識就是我們以后的財富,各位加油.
因為水平有限,難免有疏忽或者不準確的地方,希望大家能夠直接指出來,我會及時改正。一切為了知識的分享。
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 ~]# !! #執行上一條命令
fcfc 命令可以編輯曾今執行過的命令,并以批處理的形式讓這些命令重新執行
-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'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個命令
好啦,今天飛哥就講到這里,后續會有更多的精彩的內容分享給大家,希望對大家能夠有所幫助,也希望大家能多多支持飛網,讓我們共同進步。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的linux查看执行过的命令行,在Linux命令终端中查看和编辑曾执行过的命令 – LINUX笔记 – CFEI.NET...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 查看jdk的版本以及路径
- 下一篇: 三菱plc232通讯实例_三菱PLC编程