0

This question already has an answer here:

find /path/to/wordpress -type f -exec chmod 664 {} \; 

It seems that it find stuffs whose type is file and then exec chmod

What does {} and \ and ; is for?

marked as duplicate by Kusalananda, Michael Homer, Thomas, Romeo Ninov, dr01 Sep 13 '18 at 11:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

{} simply means the file returned by find, while \; it's the terminator.

Please keep in mind that \; means "execute the command for each file returned by find".

In your case

find /path/to/wordpress -type f -exec chmod 664 {} \; 

means "execute chmod 664 on each file found under /path/to/wordpress.

For example, if you have

/path/to/wordpress/file1
/path/to/wordpress/file2
/path/to/wordpress/file3

the result is equivalento to call chmod three times:

chmod 664 /path/to/wordpress/file1
chmod 664 /path/to/wordpress/file2
chmod 664 /path/to/wordpress/file3

You can also terminate the command with \+, which passes every file found as arguments for the command.

With the example above, find /path/to/wordpress -type f -exec chmod 664 {} \+ is equivalent to a single chmod:

chmod 664 /path/to/wordpress/file1 /path/to/wordpress/file2 /path/to/wordpress/file3
  • I see and doing it with \; means doing it 3 times – user4951 Sep 13 '18 at 9:16
  • @J.Chang well, it meas do it for each file, it's 3 times because there are 3 files in the example. If there are 1000 files, it will do it 1000 times ;) – Mr Shunz Sep 13 '18 at 9:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.