title: Group every nth line command output in a CSV format
body: <p>Am looking for a way to parse a multi line command output; group every multiple of <code>nth</code> line and format in CSV format.</p>
  
  <pre><code>$ cat file
  ABC
  123
  62p4-123
  DEF
  456
  62p4-456
  </code></pre>
  
  <p>I need the o/p grouped at every <code>3rd</code> line, and at multiples of 3, i.e 3rd, 6th and 9th followed by 1st,4th and 7th and 2nd, 5th and 8th respectively in comma separated format</p>
  
  <pre><code>ABC,DEF
  123,456
  62p4-123,62p4-456
  </code></pre>
  
  <p>This is just a sample format and my actual use case is a <code>json</code> o/p that I want to format using tools/utilities in <code>bash</code> and I don't need a formatting option within <code>jq</code> I used for parsing the data.</p>
  
  <p>I found several ways in <code>awk</code> like <code>awk 'NR % 3 == 0'</code> but I cannot make this repeat for other lines.</p>
  
  <p>EDIT:- Am updating my actual JSON o/p returned from <code>jq</code> here to get the most effective solution</p>
  
  <pre><code>4496
  http://xxx/yyy
  /home/build/branches/mmm/file1
  4497
  http://xxx/yyy/zzz
  /home/build/branches/mmm/file1
  4498
  http://xxx/yyy/zzz
  /home/build/branches/mmm/otherfile.c
  </code></pre>
  
  <p>Expected o/p</p>
  
  <pre><code>4496,4497,4498
  http://xxx/yyy,http://xxx/yyy/zzz,http://xxx/yyy/zzz
  /home/build/branches/mmm/file1,/home/build/branches/mmm/file1,home/build/branches/mmm/otherfile.c
  </code></pre>