Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 10 down vote accepted

You are missing the space between {} and ; :

find . -type d -exec ./script.sh {} \;
share|improve this answer
just a space.. It worked. Thanks a ton – Ashwin kumar Mar 28 '13 at 18:21


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 \{} \;
share|improve this answer
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... – Olivier Dulac Mar 28 '13 at 18:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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