標籤:c class blog code java tar
which 可以尋找可執行檔的位置
?
| 1 2 |
[email protected]:~$ which ping /bin/ping |
whereis
whereis -m 可查詢到命令的協助文檔在什麼地方
?
| 1 2 3 4 |
[email protected]:~$ whereis -m ls ls: /usr/share/man/man1/ls.1.gz [email protected]:~$ whereis -m pwd pwd: /usr/share/man/man1/pwd.1.gz |
?
| 1 2 |
[email protected]:~$ whereis pwd pwd: /bin/pwd /usr/include/pwd.h /usr/share/man/man1/pwd.1.gz |
輸出資訊有三條
1.命令本身所在目錄
2.其源檔案所在目錄
3.其協助文檔所在目錄
locate 基於本機電腦資料庫(電腦磁碟資訊),速度比find快些。locate一般是在晚上更新資料庫,但是也可以自己手動更新
?
| 1 |
[email protected]:~# sudo updatedb |
?
| 1 2 3 4 5 6 7 8 |
[email protected]:~/test# ls 1.txt 2.txt aa.tar.gz ab.tar.bz2 ac.tar ac.tar.bz2 ac.tar.gz [email protected]:~/test# locate aa.tar.gz /root/test/aa.tar.gz [email protected]:~/test# cd /tmp [email protected]:/tmp# locate aa.tar.gz /root/test/aa.tar.gz [email protected]:/tmp# |
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
建立一個新檔案,用locate試試~ [email protected]:~/test# touch aobama [email protected]:~/test# ed aobama 0 a 我是新建立的檔案, 看下locate命令能找到我麼~ . w 63 q [email protected]:~/test# locate aobama [email protected]:~/test# 結果找不到~ |
?
| 1 2 3 4 5 |
更新資料庫後看下: @IdeaPad:~/test# sudo updatedb [email protected]:~/test# locate aobama /root/test/aobama [email protected]:~/test# |
find 命令 全盤掃描,類似windows的尋找;速度比較慢
find可以基於檔案名稱尋找
?
| 1 2 3 4 5 6 |
[email protected]:~# find ./ -name ‘te*‘ ./test [email protected]:~# find ./ -name ‘1*‘ ./test/1.txt ./1.txt [email protected]:~# |