linux whatis與whatis database 使用及查詢方法(man使用實(shí)例)
通過(guò)man查找?guī)椭^(guò)程:
[chengmo@centos5 ~]$ man -h
...
f:same as whatis(1)
...
#覺(jué)得比較奇怪,whatis是什么呢?
[chengmo@centos5 ~]$ man whatis
#查詢得到是:
#whatis - search the whatis database for complete words.
#它是查詢whatis數(shù)據(jù)庫(kù)的工具
#The whatis database is created using the command /usr/sbin/makewhatis.
#里面還說(shuō),whatis數(shù)據(jù)庫(kù) 是通過(guò)/usr/bin/makewhatis建立的
收獲:whatis數(shù)據(jù)庫(kù),并且有makewhatis創(chuàng)建,whatis腳本是用作查詢的
makewhatis是怎么樣工作的呢?
[chengmo@centos5 ~]$ man makewhatis
#得到:
makewhatis reads all the manual pages contained in the given sections of manpath or the preformatted pages con-tained in the given sections of catpath. For each page, it writes a line in the whatis database; each line consists of the name of the page and a short description, separated by a dash. The description is extracted using the content of the NAME section of the manual page.
#大概意思是:makewhatis 從手冊(cè)頁(yè)配置的路徑以及領(lǐng)域范圍,搜集所有手冊(cè)頁(yè)索引信息,每個(gè)手冊(cè)頁(yè)在數(shù)據(jù)庫(kù)加入一行,這行會(huì)包括手冊(cè)頁(yè)里面name,以及簡(jiǎn)單描述。
收獲:知道這個(gè)數(shù)據(jù)庫(kù)是建立是索引,并且每個(gè)數(shù)據(jù)庫(kù)寫入一行(a line) ,會(huì)不會(huì)這個(gè)數(shù)據(jù)庫(kù)就是文本文件呢?現(xiàn)在到這里,我們不知道數(shù)據(jù)庫(kù)保存地方,也不知道它結(jié)構(gòu),只有看看whatis命令,看它是不是有源碼信息
怎么得到whatis程序源碼?
[chengmo@centos5 ~]$ type whatis
whatis is /usr/bin/whatis
#告訴路徑我們看看內(nèi)容
[chengmo@centos5 ~]$ vi /usr/bin/whatis
1 #!/bin/sh
2 #
3 # apropos -- search the whatis database for keywords.
4 # whatis -- idem, but match only commands (as whole words).
……
#它是個(gè)sh腳本,
#得到:
#grep “關(guān)鍵詞“ /var/cache/man/whatis
#它實(shí)際在查找這個(gè)文件,/var/cache/man/whatis就是上面說(shuō)的whatis 數(shù)據(jù)庫(kù)
[chengmo@centos5 ~]$ head /var/cache/man/whatis
$notes_name [Module::Build::Notes] (3pm) - Configuration for $module_name
*_unlocked [unlocked_stdio] (3) - non-locking stdio functions
#whatis數(shù)據(jù)庫(kù)就是一個(gè)文本文件記錄手冊(cè)頁(yè)的索引信息
whatis數(shù)據(jù)庫(kù)是什么時(shí)候創(chuàng)建的呢?
[chengmo@centos5 ~]$ ls -al /var/cache/man/whatis
-rw-r--r-- 1 root root 1057156 10-27 04:06 /var/cache/man/whatis
#發(fā)現(xiàn)創(chuàng)建時(shí)間是凌晨4點(diǎn)左右,看了這個(gè)是系統(tǒng)創(chuàng)建的,那么少不了cron懷疑了
[chengmo@centos5 ~]$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
有run-parts腳本運(yùn)行/etc/cron.daily目錄下面的文件
[chengmo@centos5 ~]$ cd /etc/cron.daily/
[chengmo@centos5 cron.daily]$ cat makewhatis.cron
#!/bin/bash
LOCKFILE=/var/lock/makewhatis.lock
makewhatis -u -w
……
找到了這個(gè)是由這個(gè)腳本運(yùn)行的
以上是通過(guò)man命令查找?guī)椭畔⒌囊粋€(gè)過(guò)程,有問(wèn)題,首先分析幫助是個(gè)不錯(cuò)的選擇。
作者:chengmo QQ:8292669
相關(guān)文章
shell實(shí)現(xiàn)FizzBuzzWhizz問(wèn)題示例(拉勾網(wǎng)面試題)
這篇文章主要介紹了shell實(shí)現(xiàn)FizzBuzzWhizz問(wèn)題示例(拉勾網(wǎng)面試題),需要的朋友可以參考下2014-05-05編寫shell腳本將VPS上的數(shù)據(jù)備份到Dropbox網(wǎng)盤的方法
這篇文章主要介紹了編寫shell腳本將VPS上的數(shù)據(jù)備份到Dropbox網(wǎng)盤的方法,注意Dropbox在國(guó)內(nèi)訪問(wèn)的網(wǎng)絡(luò)相關(guān)問(wèn)題,需要的朋友可以參考下2015-07-07shell腳本讀取命令行參數(shù)的實(shí)現(xiàn)
本文主要介紹了shell腳本讀取命令行參數(shù)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-07-07ping發(fā)現(xiàn)掉包報(bào)警的shell代碼
一般用來(lái)判斷服務(wù)器是否穩(wěn)定,加入crontab中讓其10分鐘跑一次,需要的朋友可以參考下2013-01-01Shell中printf和test命令的實(shí)際應(yīng)用詳解
本文主要介紹了Shell中printf和test命令的實(shí)際應(yīng)用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-09-09linux bash中too many arguments問(wèn)題的解決方法
本文介紹下在linux bash shell中出現(xiàn)too many arguments問(wèn)題的解決辦法,有需要的朋友參考學(xué)習(xí)下2013-11-11每天學(xué)一個(gè) Linux 命令之more命令
more命令,功能類似 cat ,more會(huì)以一頁(yè)一頁(yè)的顯示方便使用者逐頁(yè)閱讀,而最基本的指令就是按空白鍵(space)就往下一頁(yè)顯示,按 b 鍵就會(huì)往回(back)一頁(yè)顯示,而且還有搜尋字串的功能2016-12-12