2015年4月19日 星期日

linux search : 檔案檔名的搜尋


we know the exact name 
find . -name myFile.txt
uncertain name

find . -name “myFile*”

directory

find  / -name "apt"



whereis 


whereis ifconfig 



  • locate


locate passwd



-i  :忽略大小寫的差異;
-r  :後面可接正規表示法的顯示方式


  • find
[root@www ~]# find / -mtime 0
# 那個 0 是重點!0 代表目前的時間,所以,從現在開始到 24 小時前,
# 有變動過內容的檔案都會被列出來!那如果是三天前的 24 小時內?
# find / -mtime 3 有變動過的檔案都被列出的意思!

範例二:尋找 /etc 底下的檔案,如果檔案日期比 /etc/passwd 新就列出
[root@www ~]# find /etc -newer /etc/passwd
# -newer 用在分辨兩個檔案之間的新舊關係是很有用的!
範例五:找出檔名為 passwd 這個檔案
[root@www ~]# find / -name passwd
# 利用這個 -name 可以搜尋檔名啊!

範例六:找出 /var 目錄下,檔案類型為 Socket 的檔名有哪些?
[root@www ~]# find /var -type s
# 這個 -type 的屬性也很有幫助喔!尤其是要找出那些怪異的檔案,
# 例如 socket 與 FIFO 檔案,可以用 find /var -type p 或 -type s 來找!

沒有留言:

張貼留言