Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I work around the bash shell limitation of 'Argument list too long' when using filename wildcards that match a ton of files in /tmp/?

[my-centos4 tmp] rm -rf /tmp/myLocalFiles*
bash: /bin/rm: Argument list too long
share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

for i in myLocalFiles*; do rm -f $i; done

share|improve this answer
add comment

This is a little simpler than jáquer suggested:

find /tmp -name "myLocalFiles*" -delete
share|improve this answer
My 'find' on centos4 does not support the -delete option. –  WilliamKF Feb 1 '11 at 1:06
@WilliamKF: Then your find probably also does not support find ... -exec rm {} + –  Dennis Williamson Feb 1 '11 at 1:31
add comment

For those who can't use -delete to find command, this also works:

find /tmp -name "myLocalFiles*" -print0 | xargs -0 rm -rf
share|improve this answer
from #bash channel: "xargs(1) is dangerous (broken, exploitable, etc.) when reading non-NUL-delimited input. If you're working with filenames, use find's -exec [command] {} + instead or -print0 | xargs -0 provided you don't care about portability and like doing unnecessary extra work. Othwerwise a nice for loop." –  Edouard Lopez Sep 5 '13 at 23:25
add comment
find /tmp -name "myLocalFiles*" -exec rm -rf {} +
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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