title: How to replace 3rd word in a line using sed
body: <p>This is my 3rd post in the process of learning sed. I have a hypothetical requirement. I want to be able to replace 3rd word in each line by 'was', where words are delimited by space(s).</p>
  
  <pre><code>bash$ cat words
  hi this is me here
  hi this   is me again
  hi   this   is me yet again
   hi  this   is     me
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>hi this was me here
  hi this   was me again
  hi   this   was me yet again
   hi  this   was     me
  </code></pre>
  
  <p>Could people please help with how to do it with sed. I tried a few executing instructions, but didn't work. 
  Thanks,</p>
  
  <p>Jagrati</p>
  
  <p>I found it! I found it!</p>
  
  <p>Okay, I got the right instruction at last. This works:</p>
  
  <pre><code>sed -e 's/[^ ]*[^ ]/was/3' words
  </code></pre>