我试过了
ls -l | cut -f1 d" " | grep ".{4}rw.{4}"
例如
drwxrwx--x folder folder 4096 sep 3 19:01 dir2
我截断了第一列,并找到匹配的"rw">
但是什么也没发生
根据名称、大小或其他属性搜索文件时,使用find
不会出错。对于您的用例,尝试-perm -{mode}
,它查找设置了所有{mode}
位的文件。您可以使用数字模式,如030
或符号版本,g=rw
:
find * -perm -g=rw # search subdirectories
find * -maxdepth 0 -perm -g=rw # current directory only
以下是find(1)手册页中不同-perm
选项的完整描述:
-perm mode File's permission bits are exactly mode (octal or symbolic). Since an exact match is required, if you want to use this form for symbolic modes, you may have to specify a rather complex mode string. For example `-perm g=w' will only match files which have mode 0020 (that is, ones for which group write permission is the only permission set). It is more likely that you will want to use the `/' or `-' forms, for example `-perm -g=w', which matches any file with group write permission. See the EXAMPLES section for some illustrative examples. -perm -mode All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them. You must specify `u', `g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. -perm /mode Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify `u', `g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).