I have a text file full of several hundred lines of sequences like this:
b 29. b 52. c 84. c 83. c 94. c 93. c 61. b 38. c 81. c 92. c 28. c 37. c 27. lara@batcuter:~/.asd/a-new-way-of-studying-go$ wc -l game7 271 game7
and the following script, which separates a text file into two files, one of which consists of odd-numbered lines and one of which consists of even-numbered lines, then reads both files into a while IFS loop, printing a line from each at a time:
#/bin/bash
#testing liquor-where-twin-twas-born
awk '{print>"line-"NR%2}' $@
while IFS= read -r lineA && IFS= read -r lineB <&3; do
echo "$lineA";
echo "$lineB"
done <line-1 3<line-0
which unfortunately gives something not quite the same as the input file, due to the fact that one file was one line longer than the other.
lara@batcuter:~/.asd/a-new-way-of-studying-go$ testing-liquor game7 > test lara@batcuter:~/.asd/a-new-way-of-studying-go$ diff test game7 270a271 > b 7.
Obviously, since the file is 271 lines long, splitting it in half yields two files, one of which is 136 lines, and one of which is 135 lines. I need to fix the IFS while loop to return zero differences. At first, I thought using read ... || read ...
would help. But actually, that just bloated the output, inserting more than a single a newline between each entry, and shaving off the last line (the line that ended up in the file with the odd number of lines), as did all the other solutions I tried.