kishvet
asked on
Need to Extract an E-mail Address from a text file.
We need to extract e-mail addresses from a text file created by the MDaemon mail server. The userlist.dat is a text file with one user account per line. It does not list the e-mail address in its complete form (user1@domain1.com). It instead lists them as follows:
domain1.com user1 OtherData1a OtherData1b OtherData1c OtherData1d OtherData1e
domain2.com user2 OtherData2a OtherData2b OtherData2c OtherData2d OtherData2e
domain2.com user3 OtherData3a OtherData3b OtherData3c OtherData3d OtherData3e
Im not sure if the spaces between the domain and the user varies or if it is a tab over. But it appears that they vary based on the length of the domain name, so that the second column is vertically aligned. I think I need to use sed, but I am a complete newbie with regard to sed.
The next step is to output the file into a .map file that postfix will be able to use. I believe we know how to do that once we get a list of the complete emails (user1@domain1.com) but any hints or shortcuts here would be appreciated.
PS. The .map file will need to look like:
user1@domain1.com OK
user2@domain2.com OK
etc.
-Donald
domain1.com user1 OtherData1a OtherData1b OtherData1c OtherData1d OtherData1e
domain2.com user2 OtherData2a OtherData2b OtherData2c OtherData2d OtherData2e
domain2.com user3 OtherData3a OtherData3b OtherData3c OtherData3d OtherData3e
Im not sure if the spaces between the domain and the user varies or if it is a tab over. But it appears that they vary based on the length of the domain name, so that the second column is vertically aligned. I think I need to use sed, but I am a complete newbie with regard to sed.
The next step is to output the file into a .map file that postfix will be able to use. I believe we know how to do that once we get a list of the complete emails (user1@domain1.com) but any hints or shortcuts here would be appreciated.
PS. The .map file will need to look like:
user1@domain1.com OK
user2@domain2.com OK
etc.
-Donald
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ended up needing to use:
gawk {print$2\"@\"$1} datafile
Thanks again for the help and pointing me in the right direction.
-Donald