人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

在Linux命令終端中查看和編輯曾執(zhí)行過的命令

發(fā)布日期:2022-01-24 16:55 | 文章來源:源碼中國

history

history 命令可以用來顯示曾執(zhí)行過的命令,也可以根據(jù)顯示的治療來重新執(zhí)行需要的命令

n 顯示n個最近的記錄
-a 添加記錄
-r 讀取記錄,但不會添加內(nèi)容記錄
-w 覆蓋原有的history 文件
-c 清除記錄
-d<編號>[n] 刪除指定n條記錄
-n<文件> 讀取指定文件
-r<文件> 讀取文件但不記錄
-w<文件> 覆蓋原有文件

例1

復(fù)制代碼
代碼如下:

[root@redhat ~]# history #查看所有執(zhí)行過的命令

1 ls
2 pwd
3 fc -l
4 history

復(fù)制代碼
代碼如下:

[root@redhat ~]# history 2#顯示2條

4 history
5 history 2

復(fù)制代碼
代碼如下:

[root@redhat ~]# !4 #執(zhí)行編號是4的命令,注意感嘆號

history
1 ls
2 pwd
3 fc -l
4 history
5 history 2
6 history

復(fù)制代碼
代碼如下:

[root@redhat ~]# history -c #清除歷史記錄

!$ 引用前一個命令的最后一個參數(shù)


復(fù)制代碼
代碼如下:

[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

復(fù)制代碼
代碼如下:

[tank@localhost workspace]$ !$#取得-all

-all
bash: -all: command not found

例2

復(fù)制代碼
代碼如下:

[root@redhat ~]# ! -N #執(zhí)行倒數(shù)第N條命令
[root@redhat ~]# !!#執(zhí)行上一條命令


fc
fc 命令可以編輯曾今執(zhí)行過的命令,并以批處理的形式讓這些命令重新執(zhí)行

-1 列出第一個指令和最后一個指令之間額度所有指令
-n 不顯示編號
-r 反向排序
-e<文本編輯器> 指定文本編輯器編輯,默認Vi
-s<指令> 選擇指令執(zhí)行

例1

復(fù)制代碼
代碼如下:

[root@redhat ~]# fc -l #查看執(zhí)行過的命令,根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

復(fù)制代碼
代碼如下:

[root@redhat ~]# fc -s 358 #執(zhí)行第358個命令

expr 6 '+' 5
11

復(fù)制代碼
代碼如下:

[root@redhat ~]# fc 358 #編輯第358個命令

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部