Delete Mail from All User Accounts Print

  • 4

If you ever find yourself in a position where you need to quickly delete all messages from the mailboxes of a user account, the FIND command may be useful:

find . -type f -regex ".*\/[0-9]\..*" -exec rm {} \;

Make sure that you first navigate to the appropriate mail folder (e.g. /home/account/mail) before running the command.  The find command will location all messages that match the common mail regex format "mailbox/folder/12345678.xxxxxx" and then pass the line to the RM command.

Was this answer helpful?

« Back