Do you familiar with the option "-perm" of "find" ? I'd like to give some translation to "man find".
'-perm' option is related to file's permission. There are four kinds of parameters that '-perm' option can take :
-perm mode -perm -mode -perm /mode -perm +mode (deprecated)
 -perm mode 1 -perm mode 2 File's permission bits are exactly mode (octal or symbolic). 3 Since an exact match is required, if you want to use this form 4 for symbolic modes, you may have to specify a rather complex 5 mode string. For example -perm g=w will only match files which 6 have mode 0020 (that is, ones for which group write permission 7 is the only permission set). It is more likely that you will 8 want to use the `/' or `-' forms, for example -perm -g=w, which 9 matches any file with group write permission. See the EXAMPLES 10 section for some illustrative examples. 11 12 # 文件的權(quán)限位需要被精確匹配(八進(jìn)制或者字符表示)。 13 # 比如,-perm g=w只匹配權(quán)限是0020的文件(文件的權(quán)限中,只有g(shù)roup用戶的寫權(quán)限被賦予了。) 14 # 但其實(shí)你可能是想用 '/' '-'這兩種形式的意思。 15 # 比如, -perm -g=w,會(huì)匹配group用戶被賦予了寫權(quán)限的所有文件。 16 # [[其它權(quán)限也被賦予了也沒關(guān)系,'-'不要求精確匹配。]] 17 # 詳細(xì)的解說,參見 EXAMPLES 部分。
 -perm -mode 1 -perm -mode 2 All of the permission bits mode are set for the file. Symbolic 3 modes are accepted in this form, and this is usually the way in 4 which would want to use them. You must specify `u', `g' or `o' 5 if you use a symbolic mode. See the EXAMPLES section for some 6 illustrative examples. 7 8 # mode中列出的權(quán)限都被滿足的文件。 9 # [[mode表示的權(quán)限是某個(gè)文件的權(quán)限的子集。]] 10 # 字符形式表示的mode這種情況下也能用,而且常用。 11 # 用字符形式的時(shí)候,必須要指明'u','g','o'。 12 # 詳細(xì)的解說,參見 EXAMPLES 部分。 13
 -perm /mode 1 -perm /mode 2 Any of the permission bits mode are set for the file. Symbolic 3 modes are accepted in this form. You must specify `u', `g' or 4 `o' if you use a symbolic mode. See the EXAMPLES section for 5 some illustrative examples. If no permission bits in mode are 6 set, this test currently matches no files. However, it will 7 soon be changed to match any file (the idea is to be more con- 8 sistent with the behaviour of -perm -000). 9 10 11 12 # 對(duì)某個(gè)文件,如果mode表示的權(quán)限中任何一種被賦予了,這個(gè)文件就被匹配了。 13 # 目前,如果mode中什么權(quán)限也沒有,就匹配不到任何文件。 14 # 但不久以后,就會(huì)被修改成可以匹配任何文件。 15 #(修改后看起來更合理。和 -perm -000 的行為更一致。) 16 # [[好像什么都不匹配挺正確的,-perm /777 才應(yīng)該匹配所有文件。]] 17
 -perm +mode 1 -perm +mode 2 Deprecated, old way of searching for files with any of the per- 3 mission bits in mode set. You should use -perm /mode instead. 4 Trying to use the `+' syntax with symbolic modes will yield sur- 5 prising results. For example, `+u+x' is a valid symbolic mode 6 (equivalent to +u,+x, i.e. 0111) and will therefore not be eval- 7 uated as -perm +mode but instead as the exact mode specifier 8 -perm mode and so it matches files with exact permissions 0111 9 instead of files with any execute bit set. If you found this 10 paragraph confusing, you're not alone - just use -perm /mode. 11 This form of the -perm test is deprecated because the POSIX 12 specification requires the interpretation of a leading `+' as 13 being part of a symbolic mode, and so we switched to using `/' 14 instead. 15 16 # 這種形式被棄用了,用/mode來代替了。 17 # 繼續(xù)使用"+mode",并且使用字符形式的mode,會(huì)導(dǎo)致奇怪的結(jié)果。 18 # 比如,'+u+x' 是一個(gè)合法的字符形式的mode(數(shù)字表示是0111)[[的確是0111,待研究]] 19 # 但是,會(huì)被解釋成 -perm mode形式,而不是 -perm +mode形式。 20 # 所以,會(huì)精確匹配權(quán)限是0111的文件,而不是有一個(gè)可執(zhí)行權(quán)限就可以。 21 # 如果覺得這段有點(diǎn)繞,沒關(guān)系,很多人都覺得繞。 22 # 只要記住用/mode代替+mode就可以了。 23 # -perm +mode被棄用,是因?yàn)镻OSIX標(biāo)準(zhǔn)要求第一個(gè)加號(hào)被解釋為mode的一部分。 24 # 所以,我們用'/'代替了'+'。
Here are examples , pay more attention on the leading symbols among 'mode', '-mode' and '/mode'。
 examples 1 find . -perm 664 2 3 Search for files which have read and write permission for their owner, 4 and group, but which other users can read but not write to. Files 5 which meet these criteria but have other permissions bits set (for 6 example if someone can execute the file) will not be matched. 7 # 精確搜索權(quán)限是664的文件。 8 9 find . -perm -664 10 11 Search for files which have read and write permission for their owner 12 and group, and which other users can read, without regard to the pres- 13 ence of any extra permission bits (for example the executable bit). 14 This will match a file which has mode 0777, for example. 15 16 17 # 搜索滿足權(quán)限664的文件,不管是不是有多余的權(quán)限被賦予了。 18 # 比如,0777權(quán)限的文件也會(huì)被匹配。 19 20 find . -perm /222 21 22 Search for files which are writable by somebody (their owner, or their 23 group, or anybody else). 24 25 26 # 某個(gè)文件,如果owner,group,other中,有一個(gè)有寫權(quán)限,這個(gè)文件就被匹配。 27 28 find . -perm /220 29 find . -perm /u+w,g+w 30 find . -perm /u=w,g=w 31 32 All three of these commands do the same thing, but the first one uses 33 the octal representation of the file mode, and the other two use the 34 symbolic form. These commands all search for files which are writable 35 by either their owner or their group. The files don't have to be 36 writable by both the owner and group to be matched; either will do. 37 38 39 # 上面的三個(gè)命令的作用是一樣的,owner,group中,有一個(gè)有寫權(quán)限,這個(gè)文件就被匹配。 40 # 不需要owner和group都有寫權(quán)限。 41 42 find . -perm -220 43 find . -perm -g+w,u+w 44 45 Both these commands do the same thing; search for files which are 46 writable by both their owner and their group. 47 # 這兩個(gè)命令的作用是一樣的,owner和group都有寫權(quán)限,有多余的權(quán)限沒關(guān)系。 48 49 find . -perm -444 -perm /222 ! -perm /111 50 find . -perm -a+r -perm /a+w ! -perm /a+x 51 52 These two commands both search for files that are readable for every- 53 body ( -perm -444 or -perm -a+r), have at least one write bit set ( 54 -perm /222 or -perm /a+w) but are not executable for anybody ( ! -perm 55 /111 and ! -perm /a+x respectively). 56 # 所有人都可讀,owner,group,other有一個(gè)可寫,所有人都不可執(zhí)行的文件。 57
|