For an automated mailing and to notify user, respective members of a specific group, I am looking for commands or a single command line which provides a list of email addresses and which can be used further.
Currently I am able to look up the directory in a way like:
ldapsearch -h dc.example.com -p 389 -D "EXAMPLE\admin" -x -w "password" -b "DC=example,DC=com" -s sub "(&(objectCategory=person)(objectClass=user)(sAMAccountName=*)(memberOf=CN=Developers,OU=Role_Groups,OU=Groups,DC=example,DC=com))" mail \ | grep "mail:" \ | cut -d " " -f 2
This gives me the email addresses of all group members condensed, but not in the format for further processing I were looking for.
email@example.com firstname.lastname@example.org email@example.com ...
How to get the results in one line i.e. comma or semicolon separated?
Replacing newlines with commas using
sed wasn't working (for me).