title: How to use sed to replace characters at specific line positions?
body: <p>I am trying to process some files and I want to turn these files to .csv file, so I need to replace some specific characters(space in my case) with comma(',').
  I believed that this can be done with sed or awk, but I failed to write correct sed command.</p>
  
  <p>For example, an input file looks like below (only two lines for example)</p>
  
  <pre><code> 112 322432 434543    4555 3223
   adg gdasgg dagdag    gdag gdsg
   ...
  </code></pre>
  
  <p>Note that data in an input file is not necessarily separated by exactly one space, but it is guaranteed the input file is valid for replacing characters.
  And I need to replace every character at column position 3, 10, 17, 25 in each line.
  The corresponding output file should be like this</p>
  
  <pre><code> 112,322432,434543,   4555,3223
   adg,gdasgg,dagdag,   gdag,gdsg
   ...
  </code></pre>
  
  <p>By the way, is it possible to write a sed script (instead of hard code) that we can define an array containing positions that we need to replace space with comma.</p>
  
  <p>===================</p>
  
  <p>My bad, replacing continuous spaces does not work for my case.</p>
  
  <p><code>
  abcde abcde abcde abcde abcde
  abcde abcde    de        bcde
  </code></p>
  
  <p>The above lines show the problem I am facing, some data fields might be empty but can not be ignored. Luckily, the input file guaranteed that all data fields are placed at correct position according to project document (Every field's length is given and they are separated by a single space, although in input file there may be continuous spaces because of difference between required length in document and actual length of data).</p>