awk and mailx

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk and mailx
# 1  
Old 09-07-2011
awk and mailx

If i have a flat file record.log

Alex, San Jose, 8
Becker, Fremont, 9
Cadin, Milpitas, 9
Davin, San Jose, 10
Eric,Richmond, 10

How do i write a script to get the list of all the kids in San Jose and email me ?
I did not use script for over 10 yrs, now i forgot :-(
# 2  
Old 09-07-2011
Simple, no frills:

grep " San Jose," record.log | mailx -s "list from record" user@domain

# 3  
Old 09-07-2011
Thanks, but the out look not as i expected
Alex, San Jose, 8 Davin, San Jose, 10 Patrick, San Jose, 10 William, San Jose, 10

How do you make it like
Alex, San Jose, 8
Davin, San Jose, 10
Patrick, San Jose, 10
William, San Jose, 10

It will be nice if we get it like, separate by a tab ??

Alex San Jose 8
Davin San Jose 10
Patrick San Jose 10
William San Jose 10

Last edited by sabercats; 09-07-2011 at 08:32 PM..
# 4  
Old 09-07-2011
Not sure I'll be able to help with that. I tested sending mail to both the local system, and a main mail system and the output was placed on separate lines as expected. What are you using to read mail with? Maybe the reader isn't recognising newlines properly?
# 5  
Old 09-07-2011
I am using outlook 2010 to read it :-(
# 6  
Old 09-07-2011
Really out of my experience on that!! Last I played with anything from MS was DOS 3.something. I find it hard that they'd still insist on having a 0x0d0x0a pair as the end of line, but you could try this to see if it helps:

grep " San Jose," record.log | sed 's/$/\r/' | mailx -s "subject" user@domain

The sed should add a carriage return (\r) before the newline which might keep Outlook happy.

Not sure it will work, but easy to try.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

need help with mailx

Hi Gurus, I have a solaris zone. I am finding a issue in the situation below. When I tried to send a mail in this format its failing. : mailx -s "test mail f" But its working just fine if I use echo. echo "test body"|mailx -s "test mail " Is there... (1 Reply)
Discussion started by: rama krishna
1 Replies

2. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

3. UNIX for Advanced & Expert Users


We are using mailx to send email alerts. On occasions, it is updating our Distribution list with the mesage content. The following is the relevant portion of the script :- MAILGROUP=`more $MDS/feeds/alerts/distribution.lst` export MAILGROUP echo " " | mailx -s "MDS Alert - Refresh Complete"... (6 Replies)
Discussion started by: Paul Byrne
6 Replies

4. UNIX and Linux Applications


Hi, I am not able to send direct mails from our unix server to our lotus notes id. It was fine until we upgrade our Lotus notes server. What are the changes need to add when we upgrade Lotus notes. Please advice. It run in sh file This is the statement uuencode $RTDIR/$filename... (0 Replies)
Discussion started by: rajani_p
0 Replies

5. Shell Programming and Scripting


I would like to get a solution .. how can i attach more than one file to a mail using mailx yep........ sure if test.dat is the file cat test.dat|uuencode test.dat|mailx -s "subject" mailid can be used for attaching test.dat how can we attach test1.dat and test2.dat (4 Replies)
Discussion started by: anumkoshy
4 Replies

6. HP-UX

mailx help

Hi, I have a shell script which has code like: cat /tmp/MAIL_PCSD | mailx -m -s " PEWA Order Acknowledgement" $M1 and M1 is nothing but this M1=`echo $x | awk ' {print $3}' ` If I pass absolute email address to $M1 it works fine. But, the thing is that it gets $M1 by reading some... (3 Replies)
Discussion started by: isingh786
3 Replies

7. UNIX for Advanced & Expert Users

MAILX help

Hello all, how do I view the default mail configurations using the mailx problem? At the moment, I have an account, and all the mail to that account is being routed to an email address, how can I view this behaviour? Also, is there anyway I can view the default mail settings for a server without... (0 Replies)
Discussion started by: Khoomfire
0 Replies

8. UNIX for Dummies Questions & Answers

mailx error message : mailx: NUL changed to @

If I use the "Mail" link instead of the "mail" link to ../mailx I get this error. Mail so-n-so mailx: NUL changed to @ Unknown command: "postmaster" The email still goes through but i get the error. If I use "mail" it goes thru without the error. Any ideas?? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

9. UNIX for Dummies Questions & Answers

mailx and awk- didn't find an answer KSH

Hi folks, My input file's content: You are line1 You are line2 You are line3 etc... I need to write a script that for every line, it will send an e-mail and the body will hold the line: Output(The e-mail that will be sent): First e-mail: To: aaa Subject: bbb Body:You are line1... (4 Replies)
Discussion started by: hellsd
4 Replies

10. Shell Programming and Scripting

mailx to to Dl

Is there any way that I can mailx to a distribution list without having a $HOME/.mailrc file? We have a distribution list in Outlook for our group say I am trting to do echo "Something"|mailx -s "Subject" it doesnt work Any ideas? Thanks (1 Reply)
Discussion started by: sm321
1 Replies
Login or Register to Ask a Question