So the output of line "grep $day file2" is
"Sally Monday 8"
If you read that line as Name Day start,
you can grep $name in file1 and get the telephone number which you can then print.
However, this technique would not work for a large file, as both file1 and file2 are completely read 7 times, and sure enough as you get bigger there will be two people working on the same day, and there will be Frank A. and Frank M., or Ann and Anna.
The problem that you have stated by the way is the core issue that this forum tries to solve.
Consider setting up 7 directories (Monday thru Sunday) and removing the day from file2 and having a file named Sally containing the value 8 in the Monday directory.
so now your have:
Monday/Sally
Tuesday/Roberto
etc
Now you can change "grep Monday file2"
to
"ls Monday"
and the output is only those scheduled for Monday. You can then "cat Monday/Sally" to get the start time.
Going a step further, create directories for each person (eliminating file1) and each person's directory contains a file named phone that has the phone number as its contents.
As far as the time goes, use an if..else construct.
if $time > 12
then
print $time - 12 'pm'
else
print $time 'am'
fi
You will have to add additional code if you have shifts starting at noon and midnight.