{"id":903,"date":"2012-02-20T01:42:00","date_gmt":"2012-02-20T06:42:00","guid":{"rendered":"http:\/\/yourLinuxGuy.com\/?p=903"},"modified":"2015-04-01T16:03:23","modified_gmt":"2015-04-01T21:03:23","slug":"using-the-shell-to-transform-an-exchange-email-list","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=903","title":{"rendered":"Using the shell to transform an Exchange email list&#8230;"},"content":{"rendered":"<p>Recently, I needed to create a one-address-per-line email address list, using only an existing Exchange group mailbox as input.<\/p>\n<p>First we start in Windows&#8230;<\/p>\n<p>I opened Outlook and prepared to create a new email and typed in the email group.\u00a0 Once shown, I clicked the &#8220;plus&#8221; (+) symbol next to the group to expand it.\u00a0 Swipe across the list, and do a CTRL+C to copy them to the clipboard.<\/p>\n<p>Now, to Linux&#8230;<\/p>\n<p>Shell into a Linux box, and paste the clipboard contents into a file (for instance, input.txt).\u00a0 The input format will look a bit like this:<\/p>\n<pre><code>Jeremy Pavlov &lt;Jeremy.Pavlov@YourLinuxGuy.com&gt;; Other Guy &lt;Other.Guy@YourLinuxGuy.com&gt;<\/code><\/pre>\n<p>&#8230;and so on&#8230;<\/p>\n<p>Now run the following command against your input file:<\/p>\n<p><code>cat input.txt |tr \";\" \"\\n\" |awk '{ print $3 }' | sed s\/\"&lt;\"\/\/g |sed s\/\"&gt;\"\/\/g<\/code><\/p>\n<p>And you should end up with an output.txt that looks like this:<\/p>\n<p><code>Jeremy.Pavlov@YourLinuxGuy.com<br \/>\nOther.Guy@YourLinuxGuy.com<\/code><br \/>\n&#8230;and so on.<\/p>\n<p>This format is now perfect for use in various places, like&#8230; oh&#8230; for instance&#8230; the Subscribe2 plugin in WordPress&#8230; &#8230;Which is exactly where I use it to keep my internal subscriber list up-to-date.<\/p>\n<p>Enjoy!<\/p>\n<p>\ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>Update: For a comma-delimited list, use this:<\/p>\n<p><code>cat input.txt |tr \";\" \"\\n\"|awk '{ print $3 }'| sed s\/\"&lt;\"\/\/g |sed s\/\"&gt;\"\/\/g|tr \"\\n\" \",\"<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I needed to create a one-address-per-line email address list, using only an existing Exchange group mailbox as input. First we start in Windows&#8230; I opened Outlook and prepared to create a new email and typed in the email group.\u00a0&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=903\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,109,11,47,110,108],"tags":[],"class_list":["post-903","post","type-post","status-publish","format-standard","hentry","category-aboutthesite","category-awk","category-intermediate","category-linuxgeneral","category-sed","category-wordpress"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-ez","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=903"}],"version-history":[{"count":8,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/903\/revisions"}],"predecessor-version":[{"id":1089,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/903\/revisions\/1089"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}