How to recursively /usr/bin/find only readonly files?

I'm having trouble because, for some reason, cp -R missed a few files. And so did xcopy/s .

Since I'm running Cygwin on Win10, I decided to see if robocopy would be more effective. The trouble is someone, maybe xcopy/s or cp -R dutifully set certain files to be read only so when I try a subsequent command (after the failed recursive copy operation) it (robocopy for example) fails to copy because there is an existing file that is set to readonly.

So: how do I use

/usr/bin/find . -type f -exec chmod 777 {}; /print

to locate all (only) the read only files so I can use chmod 777 on them?

Thanks
Siegfried

Please use code tags, as recomended by the forum rules.

As owner of those files, or as root.

EDIT:
At this time of the day, i read faster than i understand the question...

If the list you're getting at this time is 'limited' (to somewhat below 1000-10000 entries), this should work just fine:

for RO in $(find . -type f);do [ -r "$RO" ] && [ ! -w "$RO" ] && echo $RO;done

hth

Before the

cp -R sourcedir targetdir

run

chmod -R u+w targetdir

Attention: on Unix systems chmod sets the permissions on a symbolic link target.

give the

-perm mode
-perm -mode
-perm /mode

tests of find a try.

Thank you everyone.

I tried google searching for the -perm mode syntax and could not find any examples. /usr/bin/find -help -perm gave some cryptic syntax summary and I still could not figure out the -perm [-/]MODE syntax. I also tried info find on Cygwin and could not find any help there either.

Could someone kindly show me some examples of using the -perm -MODE -regex syntax to find read only files?

Thanks
Siegfried
P.S. I'm still looking into sea's suggestion.

How about

find . ! \( -perm -u=w -o -perm -g=w \) 

to print files that have either user's or group's write bit missing?

2 Likes

Thanks guys! both solutions work!
Sorry for the late response -- got stuck in some serious over time.