In my assignment, a folder that represents a course is supposed to include files, each of which represents the marks of the students in that course for individual assignments. Each line consists of a student id, and a mark out of 100, separated by a single tab.
For example, you could have the file hw1 in the directory COSC-101, with the following contents:
st150 54
st173 82
st632 94
st234 100
And, also another file called hw2, with the following contents:
st632 81
st234 97
st150 71
st173 74
One of the requirements of the assignment is to average the marks across all "assignments" (i.e. files in the course directory) for every student id.
I am starting off by just attempting to get all the marks for each student into one file each.
I am trying to use a for loop to read the contents of all files, and for every unique student id create a new file (named with the format <studentid>marks) with all their marks:
cd COSC101
for file in ./*
do
cat $file | while read line; do
echo $line >> `cut -f1`marks
echo $line | cut -f2 >> `echo $line | cut -f1`marks
done
done
As you might expect, this doesn't work out too well. I just get a bunch of files that are named with a combination of both the student id and their marks, and I cannot cat them either.
Any assistance would be greatly appreciated