I have a Debian Virtual Private Server that hosts several virtual domains and users. It was configured so in order to host multiple domains and have multiple email addresses (users or accounts) under each domain name.
I do get spam quiet often, and did not have the time to look on SpamAssasin
on how to filter certain emails based on matched string in the email's body.
Instead, the following function was added to the .bash_aliases
and it was aliased for quick access use
my_new_del() {
echo "0: $1"
for d in /home/vmail/*/ ; do
# echo "1: $d"
for f in "$d"info/*/*.some.file.pattern*;do
grep -i -H -l -s "$1" "$f" | while read -r line ; do
echo "rm -rf $line"
rm -rf $line
done
# echo "2: $f"
done
done
}
alias my_del=my_new_del
Then I use the above alias:
my_del 'some string' &
The script does the job, but it is really slow, and seem inefficient. It loops through each subdirectory in the vmail directory (each subdirectory represents a domain name). Then it loops through the files in each subdirectory and then greps for the string - and deletes it if it gets a match.
Can this be done in a more efficient manner?