A solução de @LilloX deve funcionar, mas eu recomendo usar find
para o trabalho:
find . -maxdepth 1 -perm 644 | wc -l
Isso retorna o número de arquivos com permissões de leitura e gravação para o proprietário do arquivo no diretório atual. Se você remover | wc -l
do comando, ele retornará os arquivos.
Veja man find
para mais informações sobre como usar find
.
Editar:
Este é um trecho de man find
. Como você pode ver, existem muitas possibilidades de definir as permissões na pesquisa. Se você quiser corresponder arquivos que são lidos e graváveis por qualquer pessoa e também incluir arquivos que tenham permissões adicionais (executáveis), você pode usar find -perm /u+w,g+w,a+w
find . -perm 664
Search for files which have read and write permission for their owner, and group, but which other users can read but not write to. Files which
meet these criteria but have other permissions bits set (for example if someone can execute the file) will not be matched.
find . -perm -664
Search for files which have read and write permission for their owner and group, and which other users can read, without regard to the presence of
any extra permission bits (for example the executable bit). This will match a file which has mode 0777, for example.
find . -perm /222
Search for files which are writable by somebody (their owner, or their group, or anybody else).
find . -perm /220
find . -perm /u+w,g+w
find . -perm /u=w,g=w
All three of these commands do the same thing, but the first one uses the octal representation of the file mode, and the other two use the symbolic
form. These commands all search for files which are writable by either their owner or their group. The files don't have to be writable by both
the owner and group to be matched; either will do.
find . -perm -220
find . -perm -g+w,u+w
Both these commands do the same thing; search for files which are writable by both their owner and their group.
find . -perm -444 -perm /222 ! -perm /111
find . -perm -a+r -perm /a+w ! -perm /a+x
These two commands both search for files that are readable for everybody ( -perm -444 or -perm -a+r), have at least one write bit set ( -perm /222
or -perm /a+w) but are not executable for anybody ( ! -perm /111 and ! -perm /a+x respectively).