Uso simples:
find . -size +1M -delete
Se você insistir em usar xargs
e rm
com find
, basta adicionar -print0
em seu comando:
find . -size +1M -print0 | xargs -r0 rm --
Outra maneira:
find . -size +1M -execdir rm -- {} +
Em man find
:
-print0
True; print the full file name on the standard output, followed by a null
character (instead of the newline character that -print uses). This allows file names
that contain newlines or other types of white space to be correctly interpreted by
programs that process the find output. This option corresponds to the -0 option of
xargs.