title: Insert a comma after first column and before last column
body: <p>I want to insert a comma after the first column and as well as before the last column of all the lines of a file in which each line has a varying number of fields.</p>
  
  <p>E.g. this is file:</p>
  
  <pre><code>test1 test2 test3
  test1 test2 test3 test4 test5 test6
  test1 test2 test3 test4 
  test1 test2 test3 test4 test5
  </code></pre>
  
  <p>I want to make it look like:</p>
  
  <pre><code>test1, test2, test3
  test1, test2 test3 test4 test5, test6
  test1, test2 test3, test4 
  test1, test2 test3 test4, test5
  </code></pre>
  
  <p>I ma trying something like following but it is not working (either syntax error OR no expected output):</p>
  
  <pre><code>awk '{NF=NF-1;for (i=NF; i==NF; i--) $i="," print $NF }' my_file1
  </code></pre>