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

Greg Edwards greg at nas-inet.com
Fri Jan 31 10:29:18 CST 2003


Merlin wrote:
> Quoting Steve Baker <sjbaker1 at airmail.net>:
> 
> 
>>       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)
> 
> 
> Actually, I've had to do that in Windoze before, and, as a non-sequitor, how I 
> did it was load the two dir listings into separate spreadsheets, write a 
> function in another column that compared the files flagging those I was looking 
> for.  Then, I filterd based on that column and copy and pasted to another 
> spreadsheet.  I then wrote a VBA module that processed the spreadsheet and 
> created a batch file to do what I needed to.  Then all I had to do was execute 
> the batch file.
> 
> Tricky stuff can be done, just maybe not as easily as on Linux.
> 

Sometimes you guys just work way tooooo hard ;)

I don't think the original problem had alls file in another directory 
with the correct permissions.  I think he said that he had another 
directory structure setup like he wanted this one.  But assuming that 
there was a full directory template.

cd into template directory and run

find . -perm -u=w -exec chmod u=w /fixpath/"{}" ";"

This should give you a list relative to the current dir of the files 
that have write permission set for user.  The exec should set the write 
perm for user on the files relative to /fixpath/ (ie /fixpath/./name). 
You'll need to play with it a little before you really run it and run 
the same command for group and world.

I'm pretty sure this will work on all flavors of *nix and find.

-- 
Greg Edwards
New Age Software, Inc.
http://www.nas-inet.com




More information about the Discuss mailing list