Super User is a question and answer site for computer enthusiasts and power users. 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 get the error find: missing argument to-exec'` when I attempt to run the command

find . -maxdepth 1 \( -iname \*.png -o -iname \*.jpg \) -exec echo {} \; 

The reason I am using echo is because I want to make sure it is returning the results I expect before I replace it with either rm or mv. What am I doing wrong?

share|improve this question

closed as too localized by slhck Sep 15 '12 at 7:32

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

try getting rid of the superfluous dot at the end? – Sparr Sep 15 '12 at 7:20
@Sparr - Sorry added a period in the post as I ended my sentence. The period does not appear in the command I execute. – PeanutsMonkey Sep 15 '12 at 7:22
Running it on find version 4.4.2, I receive no error. It has successfully found the .png file. – bbaja42 Sep 15 '12 at 7:29
@bbaja42 - I found the issue. I was using colons as opposed to a semi-colon in the command I was executing. The example I posted was typed out and not pasted so didn't have the actual error in my syntax. – PeanutsMonkey Sep 15 '12 at 7:34

You don't need -exec... at all. Just run the command without it, and you will see what it found.

If it looks acceptable, add -delete onto the end to delete the files.

share|improve this answer
Great but I want to know how to use it with -exec. For example appending -delete would simply delete files but what if I wanted to move the files or something else. – PeanutsMonkey Sep 15 '12 at 7:24
up vote 1 down vote accepted

The issue apparently was I was using the : in my command as opposed to ;. I noticed that as I repeated the exercise having read the example at Why might -exec affect the output of find in Linux?.

The example I posted although real was typed out as opposed to copied and pasted.

share|improve this answer
I'm closing this because it's just a typo thing and thus not really reproducible for others – hope that's okay with you. – slhck Sep 15 '12 at 7:33
Right. There's no way we could have figured that out. – Michael Hampton Sep 15 '12 at 7:36
@slhck - That's okay. I only posted it so that if someone had a similar error, they would know what to look for. – PeanutsMonkey Sep 15 '12 at 7:38
@Michael Hampton - Thanks for your help though. – PeanutsMonkey Sep 15 '12 at 7:38

Not the answer you're looking for? Browse other questions tagged .