Linux基礎-7day-Linux文件查找命令find(2)

Linux件查找命令find(2)

1、按照文檔名稱查找 

1)查找/目錄下,名字爲ping的文件

[root@test ~]#find / -name ping

2)查找根目錄下ping文件,忽略大小寫

[root@test ~]#find / -iname ping

3)查找根目錄下shell目錄

[root@test ~]#find / -type d  -name shell

(4)查找根目錄下ping.sh文件

[root@test ~]#find / -type f -name ping.sh

(5)查找根目錄下所有“.sh”文件

[root@test ~]#find / -type f -name “*.sh”

2、按照文檔權限進行查找

(1)查找/目錄下,權限爲777的文件

[root@test ~]#find / -type f -perm 777

(2)查找/目錄下,只讀文件

[root@test ~]#find /  -perm /u=r

(3)查找/目錄下,可執行文件

[root@test ~]#find /  -perm /a=x

(4)查找/目錄下test.txt文件,並修改權限爲755

[root@test ~]#find /  -type f -name “test.txt” -exec chmod 755 {} \;

(5)查找/目錄下,所有空文件

[root@test ~]#find /  -type f -empty

(6)查找/目錄下test.txt文件,並刪除

[root@test ~]#find / -type f -name test.txt -exec rm -rf {} \;

3、按照文檔所有主、所有組進行查找

1)查找/目錄下,所有者爲root的所有“.sh”結尾的文件

[root@test ~]# find / -type f -user root -name "*.sh"

(2)查找/目錄下,所有組爲root的所有“.sh”結尾的文件

[root@test ~]# find / -type f -group root -name "*.sh"

4、按照日期、時間進行查找

1)查找3天內被修改過的文件

[root@test ~]#find -mtime -3

2)查找3天前被修改過的文件

[root@test ~]#find -mtime +3

3)查找3天前的當天被修改過的文件

[root@test ~]#find -mtime 3

4)查找超過3天,不超過5天內被修改過的文件

[root@test ~]#find -mtime +3 -mtime -5

5)查找1小時內被修改過的文件

[root@test ~]#find -mmin -60

6)查找1個小時內被訪問過的文件

[root@test ~]#find -amin -60

7)查找1個小時內變更過的文件

[root@test ~]#find -cmin -60

5、按照文件大小進行查找

1)查找根目錄下,大於100MB的文

[root@test ~]#find / -size +100MB

2)查找/tmp下,大於100MB的messages文件並刪除

[root@test ~]#find / -size +100MB -name messages -exec rm -rf {} \;

 

個人公衆號:

image.png

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章