1、manual說明
Display or manipulate the history list
顯示或操作命令歷史列表
2、概念區(qū)分
history list是在內(nèi)存緩存中的,history file就是在硬盤中的。history list針對(duì)當(dāng)前會(huì)話生效。history file 則針對(duì)所有會(huì)話都生效。當(dāng)?shù)卿浵到y(tǒng)系統(tǒng)時(shí),系統(tǒng)就會(huì)自動(dòng)將history list中,當(dāng)退出系統(tǒng)時(shí),history list中的命令就會(huì)自動(dòng)寫入到history file中去。
~/.bash_history 歷史列表的默認(rèn)保存位置
~/.bash_profile 當(dāng)前用戶的環(huán)境變量的設(shè)置位置
/etc/profile 系統(tǒng)環(huán)境變量的默認(rèn)設(shè)置位置
關(guān)于HISTORY的變量:
HISTSIZE 命令歷史記錄的條數(shù)
HISTFILE 指定歷史文件,默認(rèn)為~/.bash_history
HISTFILESIZE: 命令歷史文件記錄歷史的條數(shù)
HISTTIMEFORMAT: HISTTIMEFORMAT=“%F%T” 顯示時(shí)間
history用法:
history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
Display the history list with line numbers, prefixing each modified entry with a `'. An argument of N lists only the last N entries
顯示帶有行號(hào)的歷史記錄列表,并在每個(gè)修改前加上前綴
帶有“”的條目。N的參數(shù)只列出最后的N個(gè)元素。
Options:
-c: clear the history list by deleting all of the entries
通過刪除所有條目來清除歷史記錄列表
-d offset: delete the history entry at offset OFFSET
在偏移位置刪除歷史記錄項(xiàng)(就是刪除指定數(shù)字的歷史條目)
-a: append history lines from this session to the history file
將此會(huì)話的歷史記錄行追家到歷史記錄文件
-n: read all history lines not already read from the history file 。
讀取尚未從歷史文件中讀取的所有歷史記錄行
-r: read the history file and append the contents to the history list
讀取歷史文件然后追加到歷史記錄文件中
-w: write the current history to the history file and append them to the history list
將當(dāng)前歷史寫入到歷史文件中,同時(shí)將他們追加到歷史列表中。
-p: perform history expansion on each AGR and dispay the result without storing it in the history list
對(duì)每個(gè)參數(shù)執(zhí)行歷史擴(kuò)展并顯示結(jié)果,而不將其存儲(chǔ)在歷史列表中
-s: append the ARGs to the history list as a single entry
添加所有ARGs作為單獨(dú)的條目到歷史記錄條目中。
創(chuàng)新互聯(lián)專注于坡頭網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供坡頭營(yíng)銷型網(wǎng)站建設(shè),坡頭網(wǎng)站制作、坡頭網(wǎng)頁設(shè)計(jì)、坡頭網(wǎng)站官網(wǎng)定制、小程序設(shè)計(jì)服務(wù),打造坡頭網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供坡頭網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
其他比較常用的用法:
(一):查看歷史命令
history #顯示所有歷史命令’
history 10 #顯示最近的10條命令
(二)查看默認(rèn)歷史命令條數(shù):
echo $HISTSIZE
這個(gè)環(huán)境變量定義在/etc/profile中
(三)命令重新調(diào)用
ls !407 #重新調(diào)用歷史命令中的正數(shù)第407個(gè)命令
ls !-4 #重新調(diào)用歷史中的倒數(shù)第4條命令
歷史命令分兩部分存放: .bash_history 和內(nèi)存中
正常退出時(shí),內(nèi)存中的歷史命令會(huì)存儲(chǔ)到.bash_history中
(四)執(zhí)行前面倒數(shù)第一個(gè)以shut開頭的命令
!shut
(五)執(zhí)行前面一個(gè)包含go的命令
!?go
(六)執(zhí)行剛剛執(zhí)行過的命令
1、上下鍵翻
2、!-1
(七)搜索執(zhí)行過的命令
分享文章:linux中history命令的介紹和使用
文章分享:http://chinadenli.net/article0/gjegoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、做網(wǎng)站、搜索引擎優(yōu)化、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
營(yíng)銷型網(wǎng)站建設(shè)知識(shí)