Synopsis
I would like to import production data into the development environment so testing can be done in an almost accurate way. Of course I need to invalidate e-mail addresses as I don't want e-mails reaching the end-user.
Source
Just a side note - my expression deliberately matches ['] as part of the query syntax
So far I have the following using grep
which was to test my expression.
$ cat site_backup.sql | egrep -io '\w+([._-]\w*)@\w+([._-]\w*)\.\w{2,4}'
This is printing the e-mail addresses, but of course I need to replace using sed
:
$ sed -r -e "s/'(\w+)([._-]\w*)@(\w+)([._-]\w*)(\.\w{2,4})'/\1\2@invalid.\3\4\5/g" -i site_backup.sql
Works fine on a small percentage of e-mail addresses; I've noticed a pattern in what was not replaced 'word@word.ex.t'
Conclusion
After appending another expression for this, it has no affect. I still haven't looked into awk
which I know is very powerful so i'm not ignorant to it, i'm hoping someone could help.
My goal is simple, I am using mysqldump
to export a production database, I then wish to replace all e-mail addresses (or as many as reasonably possible) before importing the data in to the development environment. Am I possibly doing this from an awkward angle?