Here is the data format I am working with.
jmontgomery:Janet:Montgomery:(312)213-9876:JanetMontgomery@live.com
gstefani:Gwen:Stefani:(123)456-7890:GwenStefani@compuserv.edu
linusT:Linus:Torvadis:(987)654-3210:ltoradis@linux.org
tux:Arch:Linux:(314)921-3071:arch1@archlinux.org
Here is the output I want.
dn: uid=jmontgomery email=JanetMontgomery@live.com domain=JanetMontgomery@live.com
cn:Janet Montgomery
sn:Montgomery
telephoneNumber:(312)213-9876
dn: uid=gstefani email=GwenStefani@compuserv.edu domain=GwenStefani@compuserv.edu
cn:Gwen Stefani
sn:Stefani
telephoneNumber:(123)456-7890
dn: uid=linusT email=ltoradis@linux.org domain=ltoradis@linux.org
cn:Linus Torvadis
sn:Torvadis
telephoneNumber:(987)654-3210
dn: uid=tux email=arch1@archlinux.org domain=arch1@archlinux.org
cn:Arch Linux
sn:Linux
telephoneNumber:(314)921-3071
And my script:
BEGIN { FS=":"; ORS="\n\n" }
{ print "dn: uid="$1, "email="$5, "domain="$5 "\n" "cn:"$2,$3 "\n" \
"sn:"$3 "\n" "telephoneNumber:"$4 }
END { print "ALL DONE" }
I want to put only the domain of the email address's where "domain="$5 is. I would like to use a bash parameter expansion such as
"${$5##*@}"
But it wont let me do that.I even tried to change the FS from FS=':' to FS='@' but how could I do that for just the email address and only after it has already be processed once.I'm not against using an simple bash command such as [cut -f2 -d"@"] but how could I run that inside the awk script.I hope I explained this correctly.Thank you