Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field separator 1

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
Hi,

I want to read a file that contains email addresses and create a single string variable that contains all of the address, each address with a trialing space. The data in email_aix_users.lst looks like:

user1@my.com
user2@my.com
...

And the code looks like:

MAIL_LIST=`awk ' { print $0 } ' email_aix_users.lst `
MAIL_SUBJECT="$This_Script failed: $This_Host on $Today_Is"
/bin/mail -s&quot;$MAIL_SUBJECT&quot; &quot;$MAIL_LIST&quot; < $MAIL_BODY

I need to append a trailing space following the last entry. I've tried several things, including setting ORS, print $0&quot; &quot;, etc. Neither of which gives me the desired results and messes up the email (The subject appears in the message body along with any of the email address other then the first one, and only the first email address is used for &quot;To:&quot;).

I also tried appending a blank to the MAIL_LIST variable:

MAIL_LIST=`awk ' { print $0 } ' email_aix_users.lst `&quot; &quot;

but this causes the same messed up email as described above.

If I set MAIL_LIST=&quot;user1@my.com user2@my.com &quot;, the email process works as required.

Any ideas [idea] on what I may be doing wrong?

Spaced out...

gawker

 
MAIL_LIST=`awk ' { printf(&quot;%s &quot;, $0) } ' email_aix_users.lst `
 
vgersh99,

Once again, you've been a big help.

[thumbsup2]

Thanks!

gawker
 
comp.lang.awk also has another way to do this in discussion. The Fpat extension to awk will let you
define what your fields look like to awk, which sounds
sort of like what you may want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top