I have a script that changes the properties of the files for a folder.

Here is the example tree:

dir 1
    --file 1
    --file 2
    --file 3
dir 2
    --file 1
    --file 2
dir 3
    --file 1
    --file 2
    --file 3

I am running this command on the terminal for which I wan to run the shell script (script.sh) for every directory

find . -type d -exec ./script.sh {}\;

it does not run and errors' this:

find: missing argument to `-exec'

What am I missing here?

2 Answers 2


You are missing the space between {} and ; :

find . -type d -exec ./script.sh {} \;


find . -type d -exec /path/to/script.sh '{}' \;


find . -type d -exec /path/to/script.sh \{\} \;

or (i believe it will work too, as "}" is unambiguously not special in that case, hence literral) :

find . -type d -exec /path/to/script.sh \{} \;
  • I 1) added quotes around {} to avoid the shell to interpret {} as "launch something in the current shell" instead of the literral "{}" string. 2) added a space after it so that exec sees the expected ";" indicating the end of the exec command (that was the point making it "barf" to you) 3) put full path to the script to launch, to avoid confusion (reader and/or program) about which script is launched... Mar 28, 2013 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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