3

I am trying to find and rm -rf large files in RHEL, but what I would expect from this command that would give me purely the file directories, feeding them into rm -rf, it is not removing them. My FU might be off, so please review this line, I thought it would work.

find /tmp -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 }' | rm -rf
3
  • What about find /tmp -type f -size +50000k -delete ?
    – user49740
    Aug 5, 2013 at 16:13
  • That's exactly what worked, I was going to post an answer, but I'm taking care of something else at the moment. You can answer with that. That works.
    – FilBot3
    Aug 5, 2013 at 16:14
  • 1
    mywiki.wooledge.org/ParsingLs – why you shouldn't parse the output of ls
    – slhck
    Aug 5, 2013 at 16:16

1 Answer 1

11

You can use find /tmp -type f -size +50000k -delete instead, which is clearer, simpler and more efficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.