We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,294 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

For loop problems ...hel me

write a Unix shellscripthat 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

$file1 | sort > file1.sort

$file2 | sort > $file2.sort

echo -e "name\t days\t \phone numbers\t \Time\t"

for day in Monday Tuesday Wednesday Thursday Friday Saturday Sunday

name=`cat $file2.sort | grep $Oncall | cut -d, -f1`

if { $name }; then

phone = `cat file1.sort | grep $name | cut -d, -f2`

echo -e "$names\t \days\t \$phonenumbers \$Time

fi

done

Did I do the for loop right??

What else do i need to add to the loop.

how to loop around again??

I know how to do the convert time

2
Contributors
1
Reply
2 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
bossman5000
Newbie Poster
16 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This is a good thread to get you started.

L7Sqr
Practically a Posting Shark
851 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0598 seconds using 2.64MB