 <p>Try this:</p> <pre><code>#/bin/bash maxcount=`read wc -l file1 file2 file3 | sort -h -r | sed -rn '2s/^ *([0-9]+).*/\1/'` exec 4&lt;file1 exec 5&lt;file2 exec 6&lt;file3 while [ $maxcount -gt 0 ]; do read -a f1&lt;&amp;4 read -a f2&lt;&amp;5 read -a f3&lt;&amp;6 echo ${f1[0]},${f1[1]},${f2[0]},${f2[1]},${f3[0]},${f3[1]} ((maxcount--)) done exec 4&lt;&amp;- exec 5&lt;&amp;- exec 6&lt;&amp;- </code></pre> <p>I have hard-coded max columns for each file as 2. However, if that varies, you can get max column for each file &amp; run a loop with <code>echo -n ${f1[$i]}</code></p>