【Linux】一步一步学Linux——fc命令(224)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——fc命令(224)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 附錄
01. 命令概述
fc命令自動掉用vi編輯器修改已有歷史命令,當保存時立即執行修改后的命令,也可以用來顯示歷史命令。fc命令編輯歷史命令時,會自動調用vi編輯器。fc保存文件后,會自動執行所編輯過的命令。
02. 命令格式
用法:fc [選項] [參數]03. 常用選項
-e<文本編輯器> 指定用來編輯命令的文本編輯器,默認是vi -l 列出第一條和最后一天命令范圍內的歷史命令,如果不跟命令范圍則默認顯示最近使用過的16條歷史命令 -n 顯示歷史命令時不顯示命令序號 -r 反序顯示所有歷史命令 -s<命令名> 從歷史命令中當前位置往前找到指定命令,并執行04. 參考示例
4.1 顯示歷史命令列表(默認打印最近的16條歷史命令)
[deng@localhost ~]$ fc -l 985 ifconfig 986 ls 987 clear 988 ls 989 help seq 990 man seq 991 ls 992 clear 993 ls 994 ifconfig ens33 995 wd 996 pwd 997 ifconfig ens33 998 help set 999 ls 1000 su - root [deng@localhost ~]$4.2 指定使用vim文本編輯器編輯命令
/tmp/bash-fc-1568721904 ASCII=102,HEX=66,1,1 1-100% [deng@localhost ~]$ fc -e vim fc -l 986 ls 987 clear 988 ls 989 help seq 990 man seq 991 ls 992 clear 993 ls 994 ifconfig ens33 995 wd 996 pwd 997 ifconfig ens33 998 help set 999 ls 1000 su - root 1001 fc -l [deng@localhost ~]$4.3 顯示歷史命令列表但不顯示命令序號
[deng@localhost ~]$ fc -n fc -l 986 ls 987 clear 988 ls 989 help seq 990 man seq 991 ls 992 clear 993 ls 994 ifconfig ens33 995 wd 996 pwd 997 ifconfig ens33 998 help set 999 ls 1000 su - root 1001 fc -l [deng@localhost ~]$4.4 反序顯示所有歷史命令
[deng@localhost ~]$ fc -r fc -l 986 ls 987 clear 988 ls 989 help seq 990 man seq 991 ls 992 clear 993 ls 994 ifconfig ens33 995 wd 996 pwd 997 ifconfig ens33 998 help set 999 ls 1000 su - root 1001 fc -l [deng@localhost ~]$4.5 從歷史命令中找到ls命令,并執行
[deng@localhost ~]$ fc -s ls ls bak oradiag_deng sz12 test.sh 視頻 音樂 bj34 projects test.c test.txt 圖片 桌面 instantclient_11_2 scott_data.sql testCode 公共 文檔 oracle_client_11gR2.tar.gz share test.cpp 模板 下載 [deng@localhost ~]$4.6 顯示10條歷史命令
[deng@localhost ~]$ fc -l -10 994 ifconfig ens33 995 wd 996 pwd 997 ifconfig ens33 998 help set 999 ls 1000 su - root 1001 fc -l 1002 ls 1003 fc -l 10 [deng@localhost ~]$4.7 編輯序號為1000的命令并且執行
[deng@localhost ~]$ fc 1000 su - root 密碼:4.8 執行序號為994的命令
[deng@localhost ~]$ fc -s 994 ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 172.16.0.61 netmask 255.255.254.0 broadcast 172.16.1.255inet6 fe80::16e5:9e6b:b4d5:68de prefixlen 64 scopeid 0x20<link>ether 00:50:56:26:d8:88 txqueuelen 1000 (Ethernet)RX packets 631421 bytes 132226406 (126.1 MiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 3925 bytes 782296 (763.9 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[deng@localhost ~]$05. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——fc命令(224)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux】一步一步学Linux——l
- 下一篇: 【Linux】一步一步学Linux——s