Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

While trying my hand at writing some bash scripts I've come across various usage of the -exec parameter. In my context, I'm using it after the find command.

This guide states to use {} /; after the exec in order to pass the file name and to escape the ; so that command properly terminates.

This forum post shows the use of '{}' ';' instead of {} /;.

I tried out both methods on Ubuntu 11.04 and only the one with the single quotes is working correctly. Is there a difference between Linux versions which causes this? Are they interchangeable? Is one preferred over the other?

share|improve this question
up vote 2 down vote accepted

Your shell may assign the sequence {} a special meaning (depending on the type of shell and even if you are inside a shell script or not). To avoid this, you may either enclose it in quotes '{}' or escape it like so: \{\} (you need to use a backslash \ instead of a forward slash / like you did in your question).

Also note that the usual error message if you do it wrong (for instance, if you use ; instead of \;) is:

find: missing argument to -exec

See also the corresponding section in find's manpage.

share|improve this answer

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.