I neglected error checking. Might be file2 is at its end, and getline failed repeatedly. This doesn't depend on the files' sizes but stems from file length unbalance. Try
I am receiving same error .. it is merging good upto 1000 lines then it is starting wrong merging .. Lines are getting repeated and some line getting supressed:confused:
#!/bin/ksh
while :
do
for descriptor in 3 4
do
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14
do
IFS= read -r line || break 3
printf "%s\n" "$line"
done <&$descriptor
done
done 3< file1 4< file2
The outer loop opens the two files via descriptors 3 and 4 and does never end.
The 2nd loop toggles between the the two descriptors.
The 3rd loop reads 14 lines from the current descriptor.
The break 3 breaks out from the 3 nested loops
If the output looks good, you can redirect the whole stuff to a file