How can I get a list of non-writable files within my current directory?

link|improve this question

feedback

4 Answers

up vote 11 down vote accepted

Interpreting that as: user/group/other cannot write

find . -maxdepth 1 -not -perm /ugo+w

link|improve this answer
2  
+1 for -maxdepth 1 – Aaron Copley May 2 '11 at 19:42
feedback

This find will find files that aren't writable by anyone:

find . ! -perm /222

EDIT: From hmont's suggestion on the comment:

find . ! -perm /222 -exec ls -l {} +

And as Mikey puts on his answer, you can use -maxdepth 1 to limit the find to a single directory.

link|improve this answer
Har! You beat me by 2 seconds, but forgot the 'in the current directory' (along with everybody else). :p – MikeyB May 2 '11 at 19:32
2  
+1 because it's the clearest one. I would add a -exec ls -l {} \; to provide full information about permissions and owner/group stuff. – hmontoliu May 2 '11 at 19:34
@Mikey that can be interpreted in many ways :) But your syntax is more readable than mine on the overall. – coredump May 2 '11 at 19:34
@hmontoliu just to further refine the cmd: instead of "-exec", and since this is linux (vs. solaris et al), you can simply use the faster "-ls" option to find (the format is different, the content is mostly the same): find . -maxdepth 1 ! -perm /222 -ls – michael_n May 5 '11 at 1:03
@michael_n: good to know – hmontoliu May 5 '11 at 6:03
feedback

find . ! -perm /a+w
find . ! -perm -ug+w

or some other permutation with symbolic notation to meet your requirements.

To clarify, the '/' will match any user, group, or other. To match all, precede the mode with '-'.

link|improve this answer
feedback
perl -le 'print for grep { ! -w } <*>'
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.