title: How to check UID exists using ldapsearch
body: <p>I would like to have a shell script use 'ldapsearch' to compare UIDs listed in a text file with those on a remote LDAP directory.</p>
  
  <p>I'm no shell script expert, and would appreciate any assistance. The following loops through a text file given as an argument, but what I need is to echo when a UID in my text file does not exist in the LDAP.</p>
  
  <pre><code>#!/bin/sh
  
  for i in `cat $1`;
    do ldapsearch -x -H ldaps://ldap-66.example.com -b ou=People,dc=crm,dc=example,dc=com uid=$i | grep uid: | awk '{print $2}';
    echo $i
  done
  </code></pre>