[Linux]find命令与 perm 的 + -号

看例子:

root@debian01:~# cd test
root@debian01:~/test# ls
root@debian01:~/test# touch aaa
root@debian01:~/test# touch bbb
root@debian01:~/test# touch ccc
root@debian01:~/test# touch ddd
root@debian01:~/test# chmod 6000 aaa
root@debian01:~/test# chmod 2000 bbb
root@debian01:~/test# chmod 4000 ccc
root@debian01:~/test# chmod 6600 ddd
root@debian01:~/test# find ./ -type f -perm 6000
./aaa
root@debian01:~/test# find ./ -type f -perm -6000
./ddd
./aaa
root@debian01:~/test# find ./ -type f -perm +6000
./ccc
./bbb
./ddd
./aaa
root@debian01:~/test# 

-perm 后面不带 + 也 不带 - ,就是 完全匹配。

-perm 后面带 -, 就是说 包含了此mode的(比它宽泛的),例如 6600 包含了 6000。

-perm 后面带 +,就是此mode,或者被此mode包含的。

                          例如 6000,拆为二进制后变成:110 000 000 000,

                           6600 为:                             110 110 000 000,

                           4000 为:                             100 000 000 000

                           2000 为:                             010 000 000 000

                          和600 的非零段位与运算后,得到的都是非零值。所以都符合查询条件。

 

结束

posted @ 2013-01-25 09:45  健哥的数据花园  阅读(2916)  评论(0编辑  收藏  举报