title: Creating a name/email-textfile from the output of ldapsearch
body: <p>well, I need to generate a single text file with name and emailaddress in the format</p>
  
  <p>name, emailaddress</p>
  
  <p>from the output of ldapsearch. But that is not as simple as it looks like (at least for me).</p>
  
  <p>I am at the point where I have a list of email addresses:</p>
  
  <pre><code> ldapsearch -x -b ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,dc=&lt;somevalue&gt;,dc=&lt;somevalue&gt; objectClass=posixAccount | grep "^mail: .*$" | awk '{print $2}'
  </code></pre>
  
  <p>and a list of names:</p>
  
  <pre><code> ldapsearch -x -b ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,dc=&lt;somevalue&gt;,dc=&lt;somevalue&gt; objectClass=posixAccount | grep "^description: .*$" | awk '{print $2,$3}'
  </code></pre>
  
  <p>but whatever I tried - I don't get one single command giving me the list I need as shown above ...</p>
  
  <p>This command gives me both name and email - but not in one line:</p>
  
  <pre><code>ldapsearch -x -b ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,ou=&lt;somevalue&gt;,dc=&lt;somevalue&gt;,dc=&lt;somevalue&gt; objectClass=posixAccount | awk '/description:|mail:/{print $2,$3}'
  </code></pre>
  
  <p>Is there a way to make a cool regex to solve this?
  Or something brilliant shell command I would not think of?</p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>regards</p>
  
  <p>Dirk</p>