I am trying to scrub the emails from a SQL dump file, and I could use some advice. I am doing this because I want to send some developers "mostly correct" information, without sharing actual user information. I have a BASH script that loops through line-by-line, so I am trying to do a SED replace on the INSERT statements. I need to iterate through the dumb because I have some other scrubbing stuff, which is working. I have some regex that works (I think), but I cannot seem to get it into SED. The regex of:
'(.*@.*?)'
Will match '[email protected]', but I'm having trouble getting it into SED, and I'm sure that there is a better REGEX. Here's my example line.
'firstname','[email protected]','lastname'
I hope to be able to replace whenever I have an @ between quotes with 'empty@invalid'. Any advice would be greatly appreciated.
Try:
sed "s/'[^@']*@[^@']*'/'empty@invalid'/g"
I've replaced your .*
with the more specific [*@']*
, which only matches strings which don't have any single-quotes '
or @
, which is needed because sed
is greedy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With