title: how to double the first word in a line that have 3 words using sed?
body: <p>I have a file called <code>test</code> that have:</p>
  
  <pre><code>1 2 3
  2 3
  4 5 6 7
  8 9 10
  11 12 13 14 15 16 17
  18 19 20
  </code></pre>
  
  <p>I want to get the lines that have 3 words in them, and then print them, while the first word is duplicated. </p>
  
  <p>I cant use pipeline, and I can use >| to put it in a tmp file and read from it.</p>
  
  <p>so the output in this case is:</p>
  
  <pre><code>1 1 2 3
  8 8 9 10
  18 18 19 20
  </code></pre>
  
  <p>I understand more or less what regular expr I need, but the rest im struggling, could someone please help :?</p>
  
  <p>this is what I did:</p>
  
  <pre><code>sed 's/'^[^ ]*[ ]+[^ ]+[ ]+[^ ]+[ ]*$'/&amp;&amp;/1/ test
  </code></pre>
  
  <p>I know this is not the solution but please help me understand :/ </p>