I am pretty new to bash scripting I am amazed at everything it can do. I have hit a wall, tried a number of different combinations to get this to work and cannot seem to get it.
Any ideas / tips / answers would be greatly appreciated!
The problem: I have a file that gets dropped as part of an ldapsearch script, it contains sAMAccountName and mail attributes. These are on separate lines, I would like to: 1) take a grepped file (grep -E "sAMAccountName|mail") this produces one entry per line and output this as , which i will then feed to postmap hash:/etc/postfix/canonical (ftw).
however! my plans for world domination have been delayed because the statement where i am assigning the output of the command execution to $stuff issues command not found... grrr. Please kind internet bash gurus point out my mistakes please! note not all the code is included, just the piece that is giving me trouble: ref1: Bash regex if statement
#############################
#!/bin/bash
while read line; do
if [[ $line =~ ^sAM ]]; then
stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
echo -n $stuff >> /etc/postfix/tmp-canonical
fi
if [[ $line =~ ^mail ]]; then
stuff = $( echo "$line" | cut -d\: -f2) #<-- command not found
echo -n "<tab>$stuff\n" >> /etc/postfix/tmp-canonical
fi
done < "$1"
#end