1) Please edit your post and wrap the code and the data into [
code] tags.
2) An easy way to achieve what you want is to split the input data on section boundaries into separate files with
csplit, convert each file, then use
paste to combine them together.
Code:
#!/bin/sh
tmpdir=$(mktemp -d) || { echo Cannot create temp dir >&2;exit 1;}
trap "rm -fr -- '$tmpdir'" EXIT
fileptn='[0-9][0-9]'
csplit -sf"$tmpdir/" --suppress-matched reference.tx /^A/ '{*}'
sed -Ei 's/\s+//;s//\n/g' "$tmpdir"/$fileptn
paste "$tmpdir"/$fileptn
Provided there are always exactly three sections of the same length, another option would be
Code:
awk '/^[ \t]/{for(i=1;i<=NF;i++)print$i}' reference.tx|pr -3JT
More idiomatic
awk doing the same
Code:
awk -vOFS=\\n '!/^A/,$1=$1' reference.tx|pr -3JT
Or replace
awk with
sed if you prefer
Code:
sed '/^A/d;s/\s\+//;s//\n/g' reference.tx|pr -3JT