Today I’ve decided to cleanup the hard drive on my Linux workstation and “surprisingly” found 8G of temporary files in one folder.
After quick review I’ve decided to erase them with rm command.
For my surprise when running the command:
I got following error message:
bash: /bin/rm: Argument list too long
Conclusion:Even rm command has his limits!
Solution: Get Plumber(Joking)
Actually only Pipe is needed.
By typing following command:
find . -name "*.tmp"|less
You will see list of the files and by replacing less with xargs /bin/rm those files will be erased. Can you skip previous step? Yes you can and it is not required, but you risk to erase a lot of data if you have syntax error.
find . -name "*.tmp"| xargs /bin/rm
find . -name "*.tmp" -print0 | xargs -0 /bin/rm
find . -name "*.tmp" -delete
if you have space in file name.
Depending on the number of files and your system speed after a while all files will be erased.
(Siby) If you get Argument list too long on all commands – probably you should look at you .bashrc file.
More specifically at PATH. Did you modify it to look at subfolders?
I’m adding information from the comments to main post. Thanks to “Scriptster” and “Swynndla”
Another solution is to use -delete option applied to find command.