[email protected] /var/spool/clientmqueue # rm spam-*
/bin/rm: Argument list too long.
Ever seen this error in Linux when you have too many files in a directory and you are unable to delete them with a simple rm -rf *? I have run into this problem a number of times. After doing a bit of research online I came across a neat solution to work around this issue.
find . -name ‘spam-*’ | xargs rm
In the above instance the command will forcefully delete all files in the current directory that begin with spam-. You can replace the spam-* with anything you like. You can also replace it with just a * if you want to remove all files in the folder.
find . -name ‘*’ | xargs rm
We have covered the Linux find command in great detail earlier. Xargs is Linux command that makes passing a number of arguments to a command easier.