Fix: "bash: /bin/rm: Argument list too long"

Attempting to delete a large list of files may error with "Argument list too long".

$ rm *.log.*.gz
bash: /bin/rm: Argument list too long

The solution is to use the find command and pass the -delete option.

$ find -name "*.log.*.gz" -delete

Find the maximum number of arguments allowed:

$ getconf ARG_MAX
262144
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment