Finally, we need to loop over all the distinguished names and replace the original (old) content to the attribute with the new content:
<source lang='bash'>
for while IFS= read -r line in $result; do if [[ "$line" =~ ^dn.* ]]; then echo "# $line" fidone<<< "$result"
</source>