title: How do I get a shell script to properly shuffle array values?
body: <p>I have a fantastic shell script that works beautifully: takes a string of Unicode values and shuffles them.  Problem is that I need to make absolutely sure that each value is in a different location in the string.</p>
  
  <p>For example, if my string is (just using ascii):</p>
  
  <p>abcdefg</p>
  
  <p>I need to know that none of those chars will be in the same spot after the shuffle:</p>
  
  <p>gbadcef won't work because the "d" is in the same spot.  Taking the very last value and putting it first would work...</p>
  
  <p>fabcde</p>
  
  <p>...but it doesn't give me the randomness I need for the application.</p>
  
  <p>The actual data string is Unicode values, long, long, long semi-colon delimited strings:</p>
  
  <pre><code>&amp;#x020AE;&amp;#x0201E;&amp;#x0202E;&amp;#x02033;&amp;#x020DD;&amp;#x010AE;&amp;#x200AE;&amp;#x0009E; etc.
  </code></pre>
  
  <p>Here's the shuffle code I currently have:</p>
  
  <pre><code>#!/bin/bash
  echo "Input Filename:";
  read ifilename;
  echo "Output Filename:";
  read ofilename;
  cat $ifilename | sed -r 's/(.[^;]*;)/ \1 /g' | tr " " "\n" | shuf | tr -d "\n" &gt; $ofilename;
  </code></pre>
  
  <p>It's a great, tight, wonderful script that I think came from someone out here in the StackOverflow community.  Can anyone tell me how to modify it so that it will ensure that no character anywhere in the string accidentally ends up in the same place?</p>
  
  <p>Thank you for any and all help!</p>