I'm a newbie to bash scripting. I need help trying to figure out how to get loop through a text file and for every line take the fields of name  , project #, and email, and replace them in a email template to be sent out. So this is the text file called send.txt:Project 1,Jack,Chen,06,12,test@cs.fiu.eduProject 2,Emily,Weiss,06,12,eweiss@cs.fiu.eduProject 3,Mary,Gonzalas,06,12,Mgonz@cs.fiu.eduand this is the email template called Reminder.email:Dear __FULLNAME__: This is a kindly reminder that our __Project__ meeting will be held on today. Best Regards, CIS5027So for every line in the text file I need to replace in this email template the fields of FULLNAME: , and Project . With the corresponding values which I can do for the first line, however I cannot do it for every line.This is my script #!/bin/sh#Start your code from heredate= date +%m/%d/%yprint $date#The following line is to scan a file called Event-member.data and return any lines with todays date and save them to a file called sendtoday.txtgrep -n $(date +%m,%d) Event-member.data > sendtoday.txt#The following line is to remove the first to characters of the file created above sendtoday.txt and output that to a file called send.txt.cat sendtoday.txt | sed 's/^..//' > send.txt#This is where im having trouble. When storing the values for the variables below of name, email, project #. The value of NR==1 thus it never goes through the rest of the lines. I've tried different solutions but none seem to work.p=$(awk -F ',' 'NR==1{print $1}' send.txt)n=$(awk -F ',' 'NR==1{print $2}' send.txt)l=$(awk -F ',' 'NR==1{print $3}' send.txt)e=$(awk -F ',' 'NR==1{print $6}' send.txt)echo $p  $n  $l  $e#This part is to replace the values in the email template using sed and save the modified template as sendnow.txt.  sed -e s/__FULLNAME__:/\ $n $l :/g;s/__Project__/\ $p /g Reminder.email > sendnow.txtcat sendnow.txt#Yet to be written ... send out modified email templates.exit 0########This is the output it produces :06/12/14Project 1 Jack Chen test@cs.fiu.eduDear  Jack Chen : This is a kindly reminder that our  Project 1  meeting will be held on today. Best Regards, CIS5027As you see it did properly replace the fields but only for Jack Chen. There were 3 lines in the send.txt file so there must be 3 modified versions of the above template. 
awk for loop for each line in a file
shell script;sed;awk
There is no reason to use awk for this. You could do it directly in the shell using read. The general format is read foo bar which will save the first field as $foo and the rest of each line as $bar. So, in your case, you would do something like:while IFS=, read p n l foo bar e; do     sed -e s/__FULLNAME__:/\ $n $l :/g;s/__Project__/\ $p /g Reminder.email; done < fileThe IFS is the Input Field Separator which, when set to , reads comma delimited fields. This lets you take each field and store it in a variable. Note that I used two extra variables foo and bar. This is because each field needs its own variable name and you have 6 fields. If you only give 4 variable names, the 4th ($e) will contain the fields 4 through last.Now, there are various other syntax errors in your script. First of all the shebang line is wrong, you need #! /bin/sh, there can't be a blank line between the #! and the /bin/sh. Also, in order to assign the output of a command to a variable, you need to use the var=`command` or, preferably var=$(command) format. Otherwise, the command itself as a string and not its output is assigned to the variable. Finally, print is not what you think it is. You are looking for printf or echo. So, a better way to write your script would be:#!/bin/shdate=$(date +%m/%d/%y)echo $date## The following line is to scan a file called Event-member.data ## and return any lines with todays date and save them to a file ## called sendtoday.txtgrep -n $(date +%m,%d) Event-member.data > sendtoday.txt## The following line is to remove the first to characters of the file## created above sendtoday.txt and output that to a file called## send.txt. ## I rewrote this to avoid the useless use of cat.sed 's/^..//' sendtoday.txt > send.txt## This is where you use readwhile IFS=, read p n l foo bar e; do     sed -e s/__FULLNAME__:/\ $n $l :/g;s/__Project__/\ $p /g Reminder.email > sendnow.txt    cat sendnow.txt    ## This is where you need to add the code that sends the emails. Something    ## like this:    sendmail $e < sendnow.txtdone < send.txtexit 0########