Argument list too long

In Linux there is a maximum number of files that can be removed from a folder using:
rm -rf /home/$foldername/*

Instead, you can use the find command which will find each file in a specific folder and then remove it. This is extremely helpful when you have to remove thousands of files from a mail queue after a spam bomb.

BE CAREFUL – To remove all of the files in a folder use the following:
find /$fullpathtofolder -type f -exec rm -rf {} \;

i.e.
find /var/spool/mqueue -type f -exec rm -rf {} \;

By placing setting the -type to f you will ensure you only remove files and not folders within that folder.

Leave a Reply

You must be logged in to post a comment.