pfm200586 0 Newbie Poster

hello every one
I have a problem that drove me crazy last couple days I know I have to use loop structures but I can't figure out how to put the right pieces together. I'm not asking for a complete answer because I want to learn so please help me out
The problem says
write a shell script that will take the information from two files and combine into another file
I created both files in vi and they are


file1
David 734.854.5643
Roberto 313.432.4532
Sally 267.423.5412
Mary 435.432.7654
Ted 324.642.6743
Alice 234.576.3245
Frank 342.465.6754

and the second file is


file2
Roberto Tuesday 2
Sally Monday 8
Ted Sunday 16
Alice Wednesday 23
David Thursday 10
Mary Saturday 14
Frank Friday 15


The output file should be like this:
Name----------------On-Call--------------------Phone------------------Start Time
Sally---------------- Monday ---------------267.423.5412-----------------8am
Roberto-------------Tuesday---------------313.432.4532-----------------2am
Alice---------------Wednesday-------------234.576.3245----------------11pm
David---------------Thursday---------------734.854.5643----------------10am
Frank----------------Friday------------------342.465.6754----------------3pm
Mary---------------Saturday-----------------435.432.7654----------------2pm
Ted-----------------Sunday------------------324.642.6743-----------------4pm

I noticed right away that there is a common thing between the two files (the name), and I thought i could use for loop to cut pieces using the day of the week because I have to sorted in a specific order starting from Monday so I thought this loop might work:

for day in Monday Tuesday Wednesday Thursday Friday Saturday Sunday
do
grep $day file2
Done

I know it is not complete but I just wanted you to know how I should do the sort. And there is another problem which is the time. in the file is in 24 hours format i have to convert it to 12 hours format.
And that is it for now I want you guys just to tell me how to start and how to put the pieces together.
your help us appreciated
Thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.