Remove all mistyped emails, unsubscribed emails or bounced emails from Email List

We assume, we have following 3 files,
1. all-exported-emails.txt => this file contains list of all the emails as people have entered in subscribe form.
2. unsubscribed.txt => contains list of emails of people unsubscribed
3. bounced.txt => contains list of emails which we have already tried previosuly sending and have bounced.

 $ vim create_final_email_list.sh 
sort -u all-exported-emails.txt > unique.txt
#bash prepare_csv.sh unique.txt
rm -rf final.txt


while read line
do
        NEW_MAIL=$line

#remove unwanted character from email
if [ "$NEW_MAIL" == "${NEW_MAIL//[\,\' ]/}" ]
then
        check=$(grep -r $NEW_MAIL unsubscribed.txt)
        if [ "$check" =  "$NEW_MAIL" ]; then
                echo "email $NEW_MAIL found in unsubscribed.txt"
        else
                check2=$(grep -r $NEW_MAIL bounced.txt)
                if [ "$check" =  "$NEW_MAIL" ]; then
                        echo "email $NEW_MAIL found in bounced.txt"
                else
                        echo $NEW_MAIL >> final.txt
                fi
        fi
else
   echo "email $NEW_MAIL contains space, comma or quote.. hence ignoring"
fi

done < unique.txt
 $ bash create_final_email_list.sh 
Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply