I want to let ldap search accounts starting with z and then show only cn's (without "cn:") in reverse alphabetical order, and not case-sensitive. Also I'm trying to remove empty lines between cn's. Here's my script now. Stuck on it
ldapsearch -o ldif-wrap=no -L "(uid=z*)" cn | grep '^cn:'
Here's a solution
ldapsearch -x -L "(uid=z*)" cn | grep '^cn:' | sort -r --ignore-case | cut -c5-999