Help required regardind files deletion!

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
shakeel_jee7
Naik
Posts: 64
Joined: Sat Dec 04, 2004 6:30 pm
Location: Islamabad, Pakistan.

Help required regardind files deletion!

Post by shakeel_jee7 »

AA

I need help regarding deleting files. I have a mail Server with CentOS+exim+dovecot and Horde Webmail. Also my server has Mailbox format. I means /home/username/Maildir/new, cur, etc folders.

Today my one of my client has spamming attack from an email account which sent almost 86000+ emails in its Inox. I have blocked this user for further spamming. Now I need help to remove these files at once from the Inbox "cur" folder. Can anyone help me regarding this specifically. I have searched through internet, but could not get my required results.


Regards,
* * *
Shakeel Ahmed
Registered Linux User # 423792

"The Shortest Distance b/w a Problem & its solution, is distance between ur Knees & the Floor. The one who kneels to Allah can stand upto anything!!"
shakeel_jee7
Naik
Posts: 64
Joined: Sat Dec 04, 2004 6:30 pm
Location: Islamabad, Pakistan.

Post by shakeel_jee7 »

No one did reply!

I had found the solution at that time by doing some tricks manually with find.


find . -maxdepth 1 -type f | xargs grep -l "email address" | xargs rm -rf


Thanks for all.
* * *
Shakeel Ahmed
Registered Linux User # 423792

"The Shortest Distance b/w a Problem & its solution, is distance between ur Knees & the Floor. The one who kneels to Allah can stand upto anything!!"
azfar
Captain
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
Location: Karachi
Contact:

Re: Help required regardind files deletion!

Post by azfar »

I made one for me years back.

Code: Select all

#!/bin/bash

path=/home/azfar/scripts/mail


if [ $# -ne 2 ]
then
echo "Usage: $0 keyword keyword."
echo "Both keywords should be same."
exit
fi

if [ $1 == $2 ]
then
grep -lr "$1" $path/* > deletedfiles
no=`wc -l deletedfiles | awk '{print $1}'`
xargs rm -rf < deletedfiles
echo "$no files deleted. See the deletedfiles for details."
else
echo "Supplied keyword does not matched."
fi
change your spool path and supply a unique word to identify spam like Ip address, sender, anything unique from body or subject etc.
Azfar Hashmi
Email : azfarhashmi@hotmail.com
Post Reply