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 
sort -u all-exported-emails.txt > unique.txt
#bash unique.txt
rm -rf final.txt

while read line

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

done < unique.txt
 $ bash 
Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question