Skip to content

delete file: Argument list too long in Linux

Argument list too long in Linux

use find

find . -name filename | xargs rm -f

too many files may also cause the argument list too long problem.

-bash: /bin/find: Argument list too long

use xargs

ls | xargs -n 50 rm -rf

xargs could control the batch size of an output. In this case, 50 elements in a batch/group, and pass to rm to process progressively.

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try my iOS App