title: Simplest way to replace each occurrence of a given word by a different UUID in bash
body: <p>file.txt has multiple occurrences of the word 'dummy' and the goal is to replace each occurrence of such word by a novel UUID.</p>
  
  <p>I was wondering if there is a solution for this using a single-line command, but if not I would like the simplest possible bash script. For example, something in line with:</p>
  
  <pre><code>sed -i "s/dummy/$(uuidgen)/g" file.txt
  </code></pre>
  
  <p>unfortunately this command substitutes every word 'dummy' by the same uuid.</p>
  
  <p>e.g. </p>
  
  <p>Input:</p>
  
  <pre><code>{
  {"myid":"dummy"},
  {"myid":"ymmud"},
  {"myid":"dummy"},
  {"myid":"ymmud"},
  {"myid":"dummy"},
  {"myid":"ymmud"}
  }
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>{
  {"myid":"79769E7B-BED5-4CB5-AEF9-CCE445D9212E"},
  {"myid":"ymmud"},
  {"myid":"F2FDDD4A-4800-4F0F-911A-FEDBC82915DD"},
  {"myid":"ymmud"},
  {"myid":"52D93565-81E9-479C-8BD9-457754581BBE"},
  {"myid":"ymmud"}
  }
  </code></pre>