I have a SMTP log with records in the format below:6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,protocol,SMTP   ,745663746,STATUS-COMPLETE ,VALID6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,date,Wed, 12 Mar 2014 00:08:44 +0100     ,745663746,STATUS-COMPLETE ,VALID6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,from,example@gmail.com  ,745663746,STATUS-COMPLETE ,VALID6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,to,john@client.com,745663746,STATUS-COMPLETE ,VALID6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,subject,12 skills every lawyer must muster     ,745663746,STATUS-COMPLETE ,VALID6,222.3.4.5,3040,100.2.3.4,25,UNKNOWN,0,1,,9337bc-929a-34c0-29a8-b3a89c834b29  ,received,from [222.3.4.5] by uwl-vsd-v003.client.com with ESMTP (client SMTP Relay); Wed, 2 Mar 2013 00:06:14 +0100 from MDN-RGE-V002.client.com ([333.4.5.6]) by mdn-cbd-v001.fal.client.com (PGP Universal service); Wed, 12 Mar 2014 00:05:19 +0100 from mail-ea5-p203.google.com (HELO mail-ea5-p203.google.com) (444.5.6.7) by server-2.tower-92.example.com with RC4-SHA encrypted SMTP; 11 Mar 2014 23:06:11 -0000 from mail-ea5-p203.google.com with SMTP id I6ysd382736td.92 for <john@client>; Tues, 11 Mar 2014 16:06:10 -0700 (PDT) from nicsender ([555.6.7.8]) by mx.google.com with ESMTPSA id 87sm453982eeh.12.2014.03.11.16.06.08 for <john@client.com> (version=TLSv1cipher=LDSE-RSA-UED253-SHAbits=128/128); Tues, 11 Mar 2014 16:06:09 -0700 (PDT),745663746,STATUS-COMPLETE ,VALIDI am trying to write a bash script that anonymizes the email address in such a way that it replaces every distinct domain within the email address in the log file to a certain random string, e.g user@domain1.com gets replaced by a 234623@23423234.comuser@domain1.com gets replaced by a 232342@23423234.comuser@domain2.com gets replaced by a 232342@43534678.comThe script would keep the domain lookups in a separate file. Can someone please give me some pointers on how this could be done?
SMTP log anonymize script
shell script;regular expression