|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello Gurus, I have a question. I have a file which has 2 columns and is tab separated and looks like below: FIELD1 FIELD2 Code:
Manual m456@hotmail.com Execution din098@gmail.com Artistic m456@hotmail.com Graphic din098@gmail.com FIELD2 values will have always either of the 2 above mentioned email addresses.What i'm trying to do is sort the FIELD2 values according to the email addresses i.e. which would look like below. FIELD1 FIELD2 Code:
Manual m456@hotmail.com Artistic m456@hotmail.com Execution din098@gmail.com Graphic din098@gmail.com Now i would like to send only 1 email to the email address 'm456@hotmail.com' saying that you have two values assigned to you namely (Manual and artistic) and i would even want to send only 1 email to 'din098@gmail.com' saying that you have two values assigned to you namely (Execution and Graphic). Could anybody please help me achieve the above requirement ? Any help is highly appreciated. Last edited by Franklin52; 12-11-2012 at 04:21 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
awk 'NR>1 { print $2 | "sort | uniq" } ' input_file | while read mail_id
do
awk ' BEGIN { print "Assigned Values: " } /'$mail_id'/ { print $1 } ' input_file | mailx -s "Group Info" ${mail_id}
done |
| The Following User Says Thank You to Yoda For This Useful Post: | ||
Max499 (12-12-2012) | ||
| Sponsored Links | ||
|
|
#4
|
|||
|
|||
|
Thank you very much gurus bipinajith and rdcwayx, i really appreciate your quick help.
![]() |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks very much.
Last edited by Max499; 01-24-2013 at 03:34 PM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Missing First row-- Please help
Hi bipinajith,
Actually the code would miss the first line and it's reading from the second line. For instance if i have only one row of data, then there's no email sent to anybody. I've tried removing NR>1 but it still does the same. Can somebody help me with it please. |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
I put
NR>1 to avoid the file header
FIELD1 FIELD2 So removing NR>1 should work: Code:
awk '{ print $2 | "sort | uniq" } ' input_fileCan you explain what exactly is the issue that you are facing? |
| Sponsored Links | ||
|
![]() |
| Tags |
| awk, file, mail, sed |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need to configure mail setting to send mail to outlook mail server | amitranjansahu | UNIX for Advanced & Expert Users | 2 | 02-18-2011 06:29 AM |
| how to write a shellscript to send a mail alert to the website user based on license expiration time | deepu_Shscripts | Shell Programming and Scripting | 0 | 09-03-2010 02:55 AM |
| How to send html file in a mail not as an attachment but it should display in the mail in table for | mani_isha | UNIX for Dummies Questions & Answers | 0 | 03-30-2010 03:37 AM |
| send attachments using send mail in Solaris | mohan_kumarcs | UNIX for Advanced & Expert Users | 1 | 04-25-2009 12:36 PM |
| can not send mail from unix server to company/yahoo mail | b5fnpct | UNIX for Dummies Questions & Answers | 5 | 11-22-2002 08:24 PM |
|
|