Linux shell: find -exec in find -exec

find

I want to execute chmod 555 on all files and directories I get with the following command (it returns the directory test and all files and directories in it):

find ~/.config/google-chrome -type d -name test -exec find {} \;

Best Answer

In this very case, you can use chmod -R as per Evan's answer, but in the general case, you can do:

find ~/.config/google-chrome -type d -name test -exec sh -c '
  for i do
    find "$i" -exec chmod 555 {\} +
  done' sh {} +

The trick being to use a shell and use quoting so that the inner {} is not expanded by the outer find.

Related Question