• Uncategorized

About linux : find–readable-unknown-primary-or-operator

Question Detail

I am trying to use this command: find ./ -type f -readable -writable -exec sed -i "s/oldtext/newtext/g" {} \; to change some text in my project.

Unfortunately the terminal on macOS keeps throwing: find: -readable: unknown primary or operator. I searched on the internet but I didn’t find anything yet. Any answer is welcome.

Question Answer

I think that OSX is not using gnu find and -readable is probably a gnu extension. You might like to check in the find man page on your MAC to see if -perm option is supported; this way you can make sure that what you are looking for is both readable and writable (hopefully you are not using acl access for your project).
You will need to figure out if you are accessing the files trough user, group or global access permissions but you did say it was your project so I assume you actually own the files. If this is so I suggest you could do something like this:
find ./ -type f -perm -600 -exec sed -i “s/oldtext/newtext/g” {} ;

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.