By writing an ldapsearch
command such as:
ldapsearch -h ipaddress -p 389 -D "cn=func_01_acc,ou=admins,dc=akademia,dc=int" \
-w akademia.01 -b "ou=stud01,dc=akademia,dc=int" "(l=Torun)" sn cn telephonenumber -LLL |
grep sn: | awk '{print $2 "|" $1}' | sort | uniq -u
I got output:
dn: uid=s21705,ou=stud01,dc=akademia,dc=int
telephoneNumber: +78123793414
cn: Benny Flowers
dn: uid=s21711,ou=stud01,dc=akademia,dc=int
telephoneNumber: +78123439058
cn: Jacqueline Newton
The question is: how to format it to
Benny Flowers|+78123793414
JAcqueline Newton|+78123439058
The farest I went was:
ldapsearch -h ipaddress -p 389 -D "cn=func_01_acc,ou=admins,dc=akademia,dc=int" \
-w akademia.01 -b "ou=stud01,dc=akademia,dc=int" "(l=Torun)" sn cn telephonenumber -LLL |
grep sn: | grep dn: | sed 's/telephoneNumber: //' | sed 's/cm: //'
And I have:
+123123123
Name Surname
+123123123
Name Surname
I tried to invert number and names with:
for ((i=0;i<$elements;i++)); do
echo ${array[${i}]}
done
It printed output, but I cannot find out how to pass value to temporary array for names and for another array handling numbers.
Any suggestions would be helpful.
grep sn: | awk '{print $2 "|" $1}' | sort | uniq -u
and we can help you. I don't understand how you can get the output you say you do though after a pipe that ends insort | uniq -u
. – Alcohol