#!/usr/bin/env bash # Üllar Seerme # # The input file should consist of LDAP UIDs on every line in the # form of firstname.lastname. This input produces an output like: # "(|(uid=first.last)(uid=first.last))" to STDOUT # # The pipe in the beginning denotes a boolean OR-operator, which # specifies that at least one specified filter must be true. This # kind of output is useful for constructing an LDAP search query # where you need to check multiple UIDs. This one-liner can be # adapted for other types of queries, and I will update this when # their necessity will become apparent to me # # https://docs.oracle.com/cd/E19528-01/819-0997/gdxpo/index.html paste -d "" -s <(sed 's/\([[:alpha:]]\{1\}-\w*\|\w*\)\.\(\w*\)/(uid=\1.\2)/g; 1 s/^/"(|/; $ s/$/)"/' $1)