/bin/rm: Argument list too long?
Today, I was trying to remember the name of a file and typed ls
and the command didn't return for a couple seconds. My first thought was crap what did I just break? Then I started getting results...
[snip]
index.html.145257 index.html.189980.2 index.html.234562.1 index.html.279334.1 index.html.54784.3 index.html.99997.2
index.html.145257.1 index.html.189980.3 index.html.234562.2 index.html.279334.2 index.html.54785 index.html.99998
index.html.145257.2 index.html.189981 index.html.234562.3 index.html.279334.3 index.html.54785.1 index.html.99998.1
index.html.145257.3 index.html.18998.1 index.html.234563 index.html.279335 index.html.54785.2 index.html.99998.2
index.html.145258 index.html.189981.1 index.html.234563.1 index.html.279335.1 index.html.54785.3 index.html.99998.3
index.html.145258.1 index.html.189981.2 index.html.234563.2 index.html.279335.2 index.html.54786 index.html.99999
index.html.145258.2 index.html.189981.3 index.html.234563.3 index.html.279335.3 index.html.54786.1 index.html.99999.1
index.html.145258.3 index.html.189982 index.html.234564 index.html.279336 index.html.54786.2 index.html.99999.2
index.html.145259 index.html.18998.2 index.html.234564.1 index.html.279336.1 index.html.54786.3 index.html.99999.3
There were millions of files named index.html.* in the directory. I knew they weren't actually needed so I wanted to delete them.
# rm index.html*
bash: /bin/rm: Argument list too long
Crap.
One of the cool things about the command line is that you can do thinks like wildcard deletes like rm index.html*
but whats actually happening here is that all the files that match index.html* are being passed to rm
. In order to actually delete these files we need to use find.
find . -type f -delete -name "index.html.*"
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows