Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 7 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
add comment

try

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

or

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
add comment

Your Answer

 
discard

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.