0

This question already has an answer here:

I found some old notes where someone suggest I run the following command to set some file permissions:

find /perl/lib/ -type f -exec chmod o+r \{\} \;

Would you happen to know what the \{\} part of the statement is doing? Is it even necessary? I tested running it a few times on some test files and it seems to do the same thing as removing the backslashes:

find /u01/app/oracle/product/12102/perl/lib/ -type f -exec chmod o+r {} \;

Any help you can offer would be appreciated.

marked as duplicate by muru, Jesse_b, Thomas Dickey, Kusalananda Jun 20 at 9:47

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

The backslashes are escape characters (Telling the shell to interpret the following character literally). As you have discovered they are unnecessary. The shell will expand the two commands identically.

Someone probably thought they were necessary due to the braces being a reserved word or just wanted to be safe. However brace expansion will not occur unless there is a valid pattern within the braces, and command grouping will not be attempted unless there is a list of commands with white space between the braces.

The braces themselves in the context of a find/exec command will be substituted with each filename returned.

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