1

I have a list of files which I got using find / -type f -size +10M -exec ls -l {} \; I got this command from here

How can I remove all these files ?

I tried

sudo rm `find / -type f -size +10M -exec ls -l {} \;`

but it doesn't work.

Also, what does {} \ do ? And what's the use of -exec in this command, will the pipe operator not work ?

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
mrid
  • 5,782
  • 5
  • 28
  • 71

2 Answers2

1

I think it should be possible to have find run rm on each file found, but I couldn't get it to work.

So here is my solution using a for loop:

for $f in `find / -type f -size +10M`;do rm $f;done
AcId
  • 458
  • 2
  • 12
  • 2
    Outch! `find / -type f -size +10M -exec sudo rm '{}' +` – ceving Sep 27 '17 at 07:40
  • @ceving the `+` did the trick for me. When I tried ending the command with `\;` it just kept saying "missing argument to `-exec' – AcId Sep 27 '17 at 07:45
0

Thanks guys, I finally got it to work with @some-programmer-dude suggestion:

find / -type f -size +10M -exec rm {} \;
mrid
  • 5,782
  • 5
  • 28
  • 71