0

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?

4
  • try getting rid of the superfluous dot at the end?
    – Sparr
    Sep 15, 2012 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. Sep 15, 2012 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, 2012 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. Sep 15, 2012 at 7:34

2 Answers 2

1

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.

1
  • 1
    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. Sep 15, 2012 at 7:24
1

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.

4
  • 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, 2012 at 7:33
  • Right. There's no way we could have figured that out. Sep 15, 2012 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. Sep 15, 2012 at 7:38
  • @Michael Hampton - Thanks for your help though. Sep 15, 2012 at 7:38

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