Input file consists of multiple lines like
0 1 0 0 0 1 1 0 0 0 / 1 0 / 1 0 / 1
0 1 0 1 0 0 0 0 -1 3 / 4 1 / 4 1 / 2
I would like to copy each line in the input, insert 3 copies below the original line, and modify the fractions at the end. I would expect the output to be
0 1 0 0 0 1 1 0 0 0 / 1 0 / 1 0 / 1
0 1 0 0 0 1 1 0 0 0 / 1 1 / 2 1 / 2
0 1 0 0 0 1 1 0 0 1 / 2 0 / 1 1 / 2
0 1 0 0 0 1 1 0 0 1 / 2 1 / 2 0 / 1
0 1 0 1 0 0 0 0 -1 3 / 4 1 / 4 1 / 2
0 1 0 1 0 0 0 0 -1 3 / 4 3 / 4 0 / 1
0 1 0 1 0 0 0 0 -1 1 / 4 1 / 4 0 / 1
0 1 0 1 0 0 0 0 -1 1 / 4 3 / 4 1 / 2
The modification to the fractions follows the pattern
(0,0,0) <- original fractions
(0,+1/2,+1/2)
(+1/2,0,+1/2)
(+1/2,+1/2,0)
However, if the fraction is greater than 1
i.e. 3/4 + 1/2 = 5/4
it must have 1 subtracted from it
so 5/4 -> 1/4
Would like to add this solution to a current bash script I have. What I am showing as my "input" is the result thus far of my script. Perhaps an awk or sed command to achieve desired results?