hello, I am writing a script to send email to all the users. Can anyone provide the syntax or internet source in reading line from a dir or text document?

if users are under /home like:

student1 student2 student3
student4 student5 student6

my try is:

#!/bin/sh
line =`read`
while :
mail -s "subject" line@student.uml.edu"
mail body
. (can anyone also tell how to end sending mail in the script? . + return key is the way to send in command promp,, what about in the script? for the return key)

done < `cd /home`

When I am trying to do something to all users in the /home directory, I will do something like this:

for user in `ls /home`
do
  #insert action here
 #mail -s "Subject" -f "file" -c "${user}@student.uml.edu"
done

When I am trying to do something to all users in the /home directory, I will do something like this:

for user in `ls /home`
do
  #insert action here
 #mail -s "Subject" -f "file" -c "${user}@student.uml.edu"
done

thanks very much. It definitely answered all I need to know. Thank you.

This question has already been answered. Start a new discussion instead.