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
link|improve this question

feedback

3 Answers

up vote 2 down vote accepted

This is a little simpler than jáquer suggested:

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

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

find /tmp -name "myLocalFiles*" -print0 | xargs -0 rm -rf
link|improve this answer
feedback
find /tmp -name "myLocalFiles*" -exec rm -rf {} +
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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