[NTLUG:Discuss] how do I get a list of files that are set read-only?

Steve Baker sjbaker1 at airmail.net
Fri Jan 31 06:24:01 CST 2003


>>> I have a list of files ( lots of files... lots of sub
>>> directories. ) and I need to
>>> find out which ones are read-only. find is supposed to
>>> have a -perm option
>>> that seems like it would help, but I can't figure out how
>>> to run it.

       find . -perm +o+w -print

...lists all files and directories that have "o+w" permissions.

Do that on both directories - redirecting the results of
each onto a temporary file. Then 'diff' the temporary files,
doing a 'grep' for '<' to get the files that were o+w in the first
directory but not the second and run the output of that to another
temp file.  Now use a text editor (or 'awk' or 'sed' if you know how)
to replace every occurance of '<' with 'chmod -w' and run the
output to a fourth temp file, run that as a shell script and
you're done.

Try doing *THAT* in Windoze!  (I guess you go out and spend $200
on Norton-write-protection-unscrew-up or something)

---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net>    WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
            http://tuxkart.sf.net http://prettypoly.sf.net




More information about the Discuss mailing list