歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux命令(find中-a,-o,not的用法)

linux命令(find中-a,-o,not的用法)

日期:2017/3/3 16:56:29   编辑:關於Linux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 sudo find /etc -size +1M -exec echo {} \; #在/etc目錄下找文件大小在1M以上的文件並且顯示,文件用換行符隔開。 sudo find /etc -size +1M | xargs echo #達到-exec相同的功能但是用空格分開尋找到的文件。 #-exec後面的{} \;是不能少的。 find 緊跟的是指定開始尋找的絕對路徑,我取當前路徑。 find ./ -user 用戶名 #find後面接的是開始尋找路徑名,它會在這個路徑下遞歸尋找。 #-user 指定用戶名 find ./ -not -user 用戶名 find ./ -not -name 文件名 find ./ -not -type 類型(一般文件f,目錄d,字符文件c) #尋找不匹配的文件。 find ./ -user 用戶名 -o -type f #尋找當前目錄下用戶你指定用戶文件或者(-o)一般文件。 find ./ -size +1M -o -type d #尋找當前目錄下文件大於1M的文件或者是目錄。 find ./ -size -1M -a -type f #尋找當前目錄下文件小於1M並且文件類型是一般文件的文件。 -o 是或者的意思 -a 是而且的意思 -not 是相反的意思 根據上面再從find的尋找方式中任意組合你樂意的方式。 find /etc -not -perm mode(222) find /etc -not -perm -mode(-222) find /etc -not -perm +mode(+222) #-perm是按文件權限來查找文件 mode是完全匹配所對應的權限,如果不包括suid/sgid/sticky -mode是權限位轉化為二進制之後的1必須全部匹配,+mode則需要其中任何一個1被匹配。 -mode應該包含mode,+mode則包含-mode。
Copyright © Linux教程網 All Rights Reserved