附代碼上色實例:
<table > <tr > <td bgcolor =#7FFFD4 >
<ol >
<li > <font size ="2" color ="#CC78321"
face ='Consolas' > package
</font > <font
size = "2 " color ="#D9E8F7"
face ='Consolas' > Test
</font > <font
size ="2" color ="lavender"
face ='Consolas' > ;
</font > <br /> </li >
<ol >
</td > </tr > </table >
效果圖如下:
練習:
whereis命令只能用于搜索二進制文件(-b)、源代碼文件(-s)、說明文件(-m)。如果省略參數(shù)則返回所有的信息。
示例:
andrew
@andrew -
Thurley :~/work/iotec $ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.
1 .gz
which命令是在PATH變量指定的路徑中搜索指定的系統(tǒng)命令的位置。
示例:
andrew
@andrew -
Thurley :~/work/iotec $ which ls
/bin/ls
andrew
@andrew -
Thurley :~/work/iotec $
type命令主要用于區(qū)分一個命令到底是shell自帶的還是外部獨立的二進制文件提供的。如果是shell自帶的則會提示此命令為shell buildin,否則會列出命令的位置。
示例:
andrew@andrew-Thurley:~/work/iotec$ type ls
ls 是
`ls --color=auto' 的別名
andrew@andrew-Thurley:~/work/iotec$ type cd
cd 是 shell 內(nèi)建
andrew@andrew-Thurley:~/work/iotec$ type sh
sh 是 /bin/sh
andrew@andrew-Thurley:~/work/iotec$
locate命令實際是”find -name”的另一種寫法,但是查找方式跟find不同,它比find快得多。因為它不搜索具體目錄,而是在一個數(shù)據(jù)庫(/var/lib/locatedb)中搜索指定的文件。次數(shù)據(jù)庫含有本地文件的所有信息,此數(shù)據(jù)庫是linux系統(tǒng)自動創(chuàng)建的,數(shù)據(jù)庫由updatedb程序來更新,updatedb是由cron daemon周期性建立的,默認情況下為每天更新一次,所以用locate命令你搜索不到最新更新的文件,除非你在用locate命令查找文件之前手動的用updatedb命令更新數(shù)據(jù)庫。
示例:
andrew
@andrew -
Thurley :~/work $ locate io.c
/etc/sane.d/kodakaio.conf
/home/andrew/work/iotec/src/io.c
注意:當天創(chuàng)建的文件使用locate是查找不出來的 如使用locate查找當天創(chuàng)建的文件mcat.clocate不輸出任何的東西
andrew
@andrew -
Thurley :~/work $ locate mcat.c
andrew
@andrew -
Thurley :~/work $
find是最常用也是最強大的查找命令,它可以查找任何類型的文件。 find命令的一般格式為: find 指定目錄 指定條件 指定動作, 即find pathname -options [-print -exec -ok] 參數(shù)解釋: pathname:pathname為搜索的目錄及其子目錄,默認情況下為當前目錄 常用的option選項: -name:按文件名來查找文件 -user:按照文件的屬主來查找文件 -group:按照文件所屬的組來查找文件 -perm:按照文件權(quán)限來查找文件 -prune:不在當前指定目錄中查找
示例:
總結(jié)
以上是生活随笔 為你收集整理的linux中的五大查找命令---whereis,find,locate,which,type 的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔 推薦給好友。