Quick question on a Unix command

Soldato
Joined
14 Apr 2004
Posts
11,888
Location
UK
I'm making a small script that collects a bunch of usernames sorted into 4 assignments, it takes the marking from each one and compiles a list as follows:

Name mark1 mark2 mark3 mark4 total ave
You . . 44 . . 55 . . 66 . . 77 . . average mark

Original file is:

Login-User Name Class Mark
kjdhgf6 . . You . . . (b) . .65

I've managed split the data and retrieve selected data, I've used cut and join to do this. However I'm a little stuck on my test data. I've took out the marks for one student on one of the marks file. I was my program to default the value to 0 if any work isn't submitted.

So for example my current script does the following:

Judith Talyor 65 83 74 80 (collecting data for 4 seperate files)
John Tucker 45 (Only submitted one piece of work)

I'd like it to do the following:

John Tucker 45 0 0 0

I've been at it for a few hours trying different methods but I aint doing too well! Would appreciate any help :)
 
Last edited:
just count the number of 'works submitted' and keep track of the largest number (4 in the case above) Then when writing the data back, just zero pad the data up to the max number returned (4). seems pretty straightforward?
 
Back
Top Bottom