When you have too many files in a directory and you are unable to delete them with a simple "rm -f *" command on linux servers.
For e.g. I was trying to delete all the files under /var/spool/clientmqueue/ folder, but getting below error:
Then, I have used the following loop command to forcefully delete all files in the mentioned directory:
Try this and let us know if you have any issues.
For e.g. I was trying to delete all the files under /var/spool/clientmqueue/ folder, but getting below error:
Code:
[root@ip-172-30-0-250 clientmqueue]# rm -f * -bash: /bin/rm: Argument list too long
Code:
[root@ip-172-30-0-250 clientmqueue]# for i in `find /var/spool/clientmqueue/ -type f`; do rm -f $i; done