Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing permission for files and folder recursively using shell command in mac

In Linux we can use the following command to change permission mode of the files and folders recursively.

find "/Users/Test/Desktop/PATH" -exec * chmod 777 {} \;

how could i do the same for mac as i m getting the following error repeatatively.

find: TEST_FILE: No such file or directory

like image 903
pytho Avatar asked Sep 30 '10 20:09

pytho


People also ask

What is chmod 777 command in Mac?

Changing File Permissions Using chmod 777 It means to make the file readable, writable and executable by everyone with access.

How do I change folder permissions recursively?

You can change permissions of files using numeric or symbolic mode with the chmod command. Use the chmod command with the R (recursive) option to work on all directories and files under a given directory. The permissions of a file can be changed only with the user with sudo priviledges, or the file owner.


1 Answers

The issue is that the * is getting interpreted by your shell and is expanding to a file named TEST_FILE that happens to be in your current working directory, so you're telling find to execute the command named TEST_FILE which doesn't exist. I'm not sure what you're trying to accomplish with that *, you should just remove it.

Furthermore, you should use the idiom -exec program '{}' \+ instead of -exec program '{}' \; so that find doesn't fork a new process for each file. With ;, a new process is forked for each file, whereas with +, it only forks one process and passes all of the files on a single command line, which for simple programs like chmod is much more efficient.

Lastly, chmod can do recursive changes on its own with the -R flag, so unless you need to search for specific files, just do this:

chmod -R 777 /Users/Test/Desktop/PATH 
like image 158
Adam Rosenfield Avatar answered Sep 20 '22 19:09

Adam Rosenfield