title: bash: combine five lines of input to each line of output
body: <p>I have a input file as follows:</p>
  
  <pre><code>MB1 00134141 
  MB1 12415085 
  MB1 13253590
  MB1 10598105
  MB1 01141484
  ...
  ...
  MB1 10598105
  </code></pre>
  
  <p>I want to combine 5 lines and merge it into one line.
  I want my bash script to process the bash script to produce output as follows - </p>
  
  <pre><code>MB1 00134141 MB1 12415085 MB1 13253590 MB1 10598105 MB1 01141484
  ...
  ...
  ...                                                 
  </code></pre>
  
  <p>I have written following script and it works but it is slow for file of size 23051 lines.
  Can I write a better code to make it faster?</p>
  
  <pre><code>#!/bin/bash
  file=timing.csv
  x=0
  while [ $x -lt $(cat $file | wc -l) ]
  do
     line=`head -n $x $file | tail -n 1`
     echo -n $line " "
     let "remainder = $x % 5"
     if [ "$remainder" -eq 0 ] 
     then
          echo ""
     fi
     let x=x+1
  done
  exit 0
  </code></pre>
  
  <p>I tried to execute the following command but it messes up some numbers.</p>
  
  <pre><code>cat timing_deleted.csv | pr -at5
  </code></pre>