#! /bin/bash
readarray rows < Process.dat
for ((i=0, j=1; i< ${#rows[@]}; i++, j++)); do
declare "row$j"="${rows[$i]}"
done
echo "$row1"
the output for this code is 10110 556 4433, I have tried using the same piece of code again changing the variables of "rows" and "row" however there is no ouput when i do this, How can i split up the variable "row1" into the 3 seperate numbers each assigned to a different variable, e.g row1_1 = 10110, row1_2 = 556, row1_3 = 4433
the input file consists of 5 rows and 3 columns of numbers:
10110 556 4433
10120 424 54
12452 123 534
22042 432 12
25321 423 73
The columns represent index time, burst time and id number respectively.
I need to work out:
- execution order,
- average wait time,
- average completion time
e.g execution order 4433>54>534>12>73.
average completion time = 6132/5
(556+(556+424)+(556+434+123)+(556+424+123+432)+(556+424+123+432+423)) / 5
average wait time = 4174/5
(0+556+(556+424)+(556+424+123)+(556+424+123+432)) / 5
the endgame is to have each of these numbers assigned to a unique variable that I can later use to do math operations
output from od -c Process.dat
0000000 0 1 0 1 3 4 7 5 6 4 4 4 3 \r
0000020 \n 0 1 0 1 3 6 7 4 2 \r \n 0 1
0000040 2 1 4 5 1 6 1 \r \n 0 2 1 2 4
0000060 4 7 2 3 \r \n 0 2 2 1 4 5 7
0000100 1 5 5
0000104
the values are different because i am using the example file to check outputs against the example outputs but should still act in the same way
example file and outputs
010134 756 443
010136 7 42
012145 16 1
021244 72 3
022145 71 55
outputs:
avg comp = 4141/5
avg wait = 3149/5