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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to recursively /usr/bin/find only readonly files?
# 1  
Old 01-11-2016
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
Code:
/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

Last edited by Don Cragun; 01-11-2016 at 09:04 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 01-11-2016
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:
Code:
for RO in $(find . -type f);do [ -r "$RO" ] && [ ! -w "$RO" ] && echo $RO;done

hth

Last edited by sea; 01-11-2016 at 07:31 PM..
# 3  
Old 01-12-2016
Before the
Code:
cp -R sourcedir targetdir

run
Code:
chmod -R u+w targetdir

Attention: on Unix systems chmod sets the permissions on a symbolic link target.
# 4  
Old 01-12-2016
Quote:
Originally Posted by siegfried
.
.
.
]to locate all (only) the read only files so I can use chmod 777 on them?
.
.
.
give the
Code:
-perm mode
-perm -mode
-perm /mode

tests of find a try.
# 5  
Old 01-14-2016
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.
# 6  
Old 01-14-2016
How about
Code:
find . ! \( -perm -u=w -o -perm -g=w \)

to print files that have either user's or group's write bit missing?
These 2 Users Gave Thanks to RudiC For This Post:
# 7  
Old 02-04-2016
Thanks guys! both solutions work!
Sorry for the late response -- got stuck in some serious over time.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/usr/bin/ld: cannot find -lboost_regex-mt

...... (30 Replies)
Discussion started by: larry burns
30 Replies

2. UNIX and Linux Applications

/usr/bin/ld: cannot find -lz error

I am installing lxml module for python on redhat I have installed libxml2 already. When I run for libxslt: ./configure --prefix=libxslt_folder --with-libxml-prefix=libxml2_folder It is ok the I run : make I have error: /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status I... (4 Replies)
Discussion started by: AIX_30
4 Replies

3. Shell Programming and Scripting

How to download recursively a folder using /usr/bin/ftp and cshell?

Hi, friends, I am meet a ftp download problem when using cshell and /usr/bin/ftp command. I want to download recursively a folder dira from FTP server. dira ---dira1-----dira2------dira3-----dira4 |--file11 |--file21 |--file31 |--file41 |--file12 |--file22 |--file32 ... (1 Reply)
Discussion started by: weichanghe2000
1 Replies

4. Programming

/usr/bin/ld: cannot find -lpam

I'm trying to compile sudo on RHEL 4.8 and during the make I get the this error. Does anyone know what package I'm missing? gcc -o sudo sudo_auth.o pam.o mkstemps.o ldap.o exec_pty.o get_pty.o iolog.o audit.o boottime.o check.o env.o exec.o getspwuid.o gettime.o goodpath.o fileops.o find_path.o... (2 Replies)
Discussion started by: woodson2
2 Replies

5. Shell Programming and Scripting

how to use use /usr/bin/find for 4 digit year dirs only

I have lots of directories in ~/. My diaries are stored in directories in ~/ containing exactly 4 digits. How do I use the /usr/bin/find command to only search my diary directories? So I would like my search to include ~/2009/abc/def and ~/2010/2001/33 but not ~/103/ or ~/20101/ or ~/201/... (2 Replies)
Discussion started by: siegfried
2 Replies

6. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

7. Programming

can't compile under cygwin anymore, /usr/bin/ld: cannot find crt2.o etc

I have been compiling software under gcc3.4.4-999 cygwin for some time now. I was having an issue, so I decided to re-install gcc. After the re-install, I am getting the following errors from the linker, /usr/bin/ld: cannot find crt2.o: No such file or directory /usr/bin/ld: cannot find... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

8. Red Hat

/usr/bin/find && -exec /bin/rm never work as expected

hi there, Would you able to advise that why the syntax or statement below couldn't work as expected ? /usr/bin/find /backup -name "*tar*" -mtime +2 -exec /bin/rm -f {} \; 1> /dev/null 2>&1 In fact, I was initially located it as in crontab job, but it doesn't work at all. So, I was... (9 Replies)
Discussion started by: rauphelhunter
9 Replies

9. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question