Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 try to run (unix-shell, win7):

find . -maxdepth 1 -name "*.jpg" -size -50k -delete

and get the error:

find: invalid predicate '-delete'

any hints?

share|improve this question
up vote 5 down vote accepted

You may also find the xargs is helpful, not only in find & delete operations, but, in others where you may want to process text after you run a command. In this case,

find . -maxdepth 1 -name "*.jpg" -size -50k | xargs rm -f

Always make sure you check your work with an "echo" before xargs, first (so you can see what the commands look like before you run it). Which would look like:

find . -maxdepth 1 -name "*.jpg" -size -50k | xargs echo rm -f
share|improve this answer
The version with echo won't include the files found by find; it ignores the input and echoes the literal string 'xargs rm -f'. – chepner May 7 '13 at 21:28
Thanks - xargs is the slickest, I guess.. One thing though: how to include filenames with spaces. IFS=$'\t\n' didn't work for me.. And, would there be a command that puts the files to the bin, instead of deleting them permanentely? – Kay May 8 '13 at 7:56
@Kay -- No prob! For the spaces, what you'll want to do is position the argument in xargs with the "-i" flag. Like... find . | xargs -i rm -f "{}" So -i says "I'm going to posItion the argument" and the {} says "Here's where I want to position it". Then the quote to tell your shell "Hey man, there's junk in this thing, so, yeah just take the stuff in the quotes". – dougBTV May 8 '13 at 13:58
@Chepner -- oops! I had the echo in the wrong place. I moved it, it should work as I meant it, now. – dougBTV May 8 '13 at 14:03
@Kay -- reread, about putting them in a bin, I'd move them to /tmp. You can do the same thing using the position, like.... find . | xargs -i mv "{}" /tmp/ – dougBTV May 8 '13 at 14:22

The version of find found from the unix shell you are running (from windows) lacks the -delete predicate.

An possible alternative is-:

find . -maxdepth 1 -name "*.jpg" -size -50k -exec rm {} \;
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.