Good afternoon everyone, I have a project I am working on, but I am having a bit of trouble with it. I am supposed to create a script that uses a loop structure to output data from 2 data files.
These are the two data files:
data1:
Dave,7348389800
Bob,3131234567
Carol,2483445576
Mary,3134491390
Ted,2484962204
Alice,6165564458
data2:
Bob,tuesday
Carol,friday
Ted,sunday
Alice,wednesday
Dave,thursday
Mary,saturday
This is how it is supposed look when i display it:
Day Name Phone
__________________________________________
MONDAY Nobody
TUESDAY Bob (313) 123-4567
WEDNESDAY Alice (616) 556-4458
THURSDAY Dave (734) 838-9800
FRIDAY Carol (248) 344-5576
SATURDAY Mary (313) 449-1390
SUNDAY Ted (248) 496-2204
This is my current code:
#!/bin/ksh
for day in monday tuesday wednesday thursday friday saturday sunday
do
day=`grep -i day data2 |cut -d "," -f 2 `
name=`cut -d "," -f 1 data1 `
phone=`cut -d "," -f 2 data1`
done
echo $day $name $phone >>output
And this is the output I am getting:
Day Name Phone
==============
tuesday friday sunday wednesday thursday saturday Dave Bob Carol Mary Ted Alice 7348389800 3131234567 2483445576 3134491390 2484962204 6165564458
Any help would be greatly appreciated!
dayfor both the iteration and the variable inside the loop;grep -i dayshould begrep -i $day