Linux Command Line Example To Remove Emails From a Text File

sed is a really powerful Linux command line utility. It can in a one line do what would take sometimes 20-30 lines of code in python. This single command will replace all email addresses inside the file “myfile.csv” with the text “****@emailredact.ed”.

sed -r -i 's/\b[A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\.[a-z]{2,30}\b/****@emailredact.ed/' myfile.csv

Leave a Reply

Your email address will not be published.