This afternoon, whilst trying to clear abit of disk space on my Debian box, I found I have a crontab running that logs everytime it runs. There are about 100 000 logs already.
The file names are maintenance.php.4723, maintenance.php.4724 etc.
So I just quickly ran the command
rm maintenance.php.*
Then it prompted me with the error
/bin/rm: Argument list too long
But why, I’m sure I’ve used this many time before and sure it should work.
So again, “Google is my friend” and I found a blog post where the same problem was experienced by this guy in 2004 already.
His solution involved piping the results of a find to rm one by one.
Use find to pipe all the matching files to rm, one at a time.
find . -name ‘maintenance.php*’ | xargs rm