Hey!
I'm new to scripting so I hope You can help.
I have /etc/aliases file where are e-mails and aliases, for example:
john.smith@asd.com john
mary.smith@asd.com msmith
And I have e-mail list with people in that list as a file. The problem is that aliases and e-mails are mixed. Like:
john.smith@asd.com
msmith
But I'd like to have there ONLY e-mails. Like:
john.smith@asd.com
mary.smith@asd.com
So I was trying to use awk to sort it out, but it seems that it's bit complicated...
Here's what I got:
#!/bin/bash
for short_email_list in `cat short_ones`
do
short_name=`echo $short_email_list | awk -F \@ '{ print $1}'`
full_name=`grep :"[[:space:]]\{1,\}"$short_name /etc/aliases | grep "\." | awk -F : ' {print $1} '`
echo "Full name:" $full_name ", Short name:" $short_name
done
Could anyone help out with that?
Thank You!
I'm new to scripting so I hope You can help.
I have /etc/aliases file where are e-mails and aliases, for example:
john.smith@asd.com john
mary.smith@asd.com msmith
And I have e-mail list with people in that list as a file. The problem is that aliases and e-mails are mixed. Like:
john.smith@asd.com
msmith
But I'd like to have there ONLY e-mails. Like:
john.smith@asd.com
mary.smith@asd.com
So I was trying to use awk to sort it out, but it seems that it's bit complicated...
Here's what I got:
#!/bin/bash
for short_email_list in `cat short_ones`
do
short_name=`echo $short_email_list | awk -F \@ '{ print $1}'`
full_name=`grep :"[[:space:]]\{1,\}"$short_name /etc/aliases | grep "\." | awk -F : ' {print $1} '`
echo "Full name:" $full_name ", Short name:" $short_name
done
Could anyone help out with that?
Thank You!