That’s maybe some common Error you’re receiving, when you’re new to find and the exec parameter. So I encountered the Problem as well.
After a short research within the man page of find the problem was found: ‘;‘ needs to be escaped with a Backslash ‘\‘. The look over to my commandline just showed that this was already the case. Now the internet was asked and most results just reveal the same thing: escape the ; with a Backslash.

Some hits later I found a german page where they told that it’s even required that the ‘\;‘ is separated from the previous commands with a space ‘ \;‘. So it’s not enough to write -exec command ‘{}\;‘ it needs to be -exec command ‘{} \;‘ . Well from my point of view some mistake which can be fast overseen, even more if you suppose that ‘{}\;‘ should work out nicely as it’s something which occurs often or everytime within the exec(at least these groups of signs).

Just something new learnt, and hopefully for a few people less headache.

Tags: none

Tags: -exec, find
3 Responses to “find: missing argument to `-exec`”
  1. Leonard says:

    Thanks. It helped me today.

  2. xsaimex says:

    Thanks dude. Was looking for a solution!

  3. mc says:

    Thank you so much for your help. i’ve been working on a script to delete files in a hom directory and have been messing with this for about 2 hours. This statement very picky with the sytax. here is what worked for me.

    sudo find /home/test -mtime +2 -exec rm -f {} \;

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Bad Behavior has blocked 18338 access attempts in the last 7 days.