Using `find -perm` to find when a permission is not set

左心房为你撑大大i 提交于 2019-12-17 22:33:39

问题


I want to find the non-readable files in my directory (eg the files with g-r). So I tried this:

find . -perm -g-r

It shows me all of the files?? So I tried this:

find . -perm -g+r

And it showed me only the readable files. It appears that -perm -g-r matches all files. I'm using CentOS 5.5. Am I doing something wrong? It doesn't look like -perm -g-r does anything useful.


回答1:


Try:

find . ! -perm -g+r




回答2:


If you want to find files that are non-readable by you, you could use

find . ! -readable



回答3:


You were able to see all files when you executed the below instruction, because you were executing it as root.

find . -perm -g-r

Try executing as a normal user.



来源:https://stackoverflow.com/questions/4382599/using-find-perm-to-find-when-a-permission-is-not-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!