My input file is of the form:
0 1 0 0 0 1 1 0 0 0 / 1 0 / 1 0 / 1
0 1 0 3/4 1 0 0 1/4 0 0 -1 1/2
0 -1 0 1/4 -1 0 0 3/4 0 0 1 1/2
I want to rearrange the order of the lines that have the fraction within them. Currently I have:
#!bin/bash
filename="input.txt"
while ((i++)); read -r line; do
re='[0-9][/][0-9]';
if [[ $line =~ $re ]]
then
echo $line
fi
done < "$filename"
which will echo the second and third line. Is there an awk or sed command I could use to get these two lines to change their order (leaving the first as is) to being
$1,$2,$3,$5,$6,$7,$9,$10,$11,$4,$8,$12
which would make my file now look 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
0 -1 0 -1 0 0 0 0 1 1/4 3/4 1/2