SEX! or, how do I mail to a lot of unix users?

Mostly Harmless jdarcy at zelig.encore.com
Fri Jun 1 01:45:59 AEST 1990


thermal%solgel.hepnet at CSA2.LBL.GOV:
> I would like to be able to send a mail message to all the users on
> a unix machine.  Of course, I could do it the long way, that is,
> do a 'finger' or 'who', thus getting a list of all the users, and
> then sending a mail message to each, one at a time.  Is there a
> quicker way? 

The simplest way I can think of is:

    mail `awk -F: '{print $1;}' < /etc/passwd`

This simply extracts the username field from every entry in /etc/passwd.  Of
course, if you're using YP you'll have to do something more like:

    mail `ypcat passwd | awk -F: '{print $1;}'`

I'm sure you get the idea.

Jeff d'Arcy, Generic Software Engineer - jdarcy at encore.com
      Nothing was ever achieved by accepting reality



More information about the Comp.unix.wizards mailing list