Help required regardind files deletion!

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

Help required regardind files deletion!

Postby shakeel_jee7 » Thu Jul 14, 2011 4:17 pm

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.

Postby shakeel_jee7 » Thu Jul 21, 2011 6:43 pm

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!!"
shakeel_jee7
Naik
 
Posts: 64
Joined: Sat Dec 04, 2004 6:30 pm
Location: Islamabad, Pakistan.

Re: Help required regardind files deletion!

Postby azfar » Fri Dec 23, 2011 3:50 pm

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
azfar
Captain
 
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
WLM: azfarhashmi@hotmail.com
Yahoo Messenger: azfarhusain@yahoo.com
Location: Karachi


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron