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

Leo de Wit leo at ehviea.ine.philips.nl
Wed Jun 6 02:33:03 AEST 1990


In article <1990May31.230138.14896 at iwarp.intel.com> merlyn at iwarp.intel.com (Randal Schwartz) writes:
|In article <JASON.90May31163242 at aelle.cs.odu.edu>, jason at cs (Jason C Austin) writes:
|| #!/bin/sh
|| 
|| users=`cat user-list`

1 fork, 1 exec.

|| 
|| for user in $users
||  do
||   echo "Mailing $user"
||   mail $user < message
||  done
|

2 forks & 2 execs for each user.

|
|Too many processes.  If you want progress reporting, say:
|
|while read user
|do
|	echo "Mailing $user"
|	mail $user <message
|done <user-list
|

1 fork for the redirected while, 2 forks & 2 execs for each user.

Number of processes is the same (but you save an exec).
Alternative:

set -x     # Let the shell do the progress report.
for user in `cat user-list`; do mail $user <message; done

(1 fork & 1 exec for cat, 1 fork & 1 exec for each user).

Of course, for builtin echo's, not-forked redirected while loops the
situation differs.

    Leo.



More information about the Comp.unix.questions mailing list