title: How to print words n words in shell ?
body: <p>This is what I have tried. It works but sometimes the words printed are not of $len size. </p>
  
  <pre><code>LINE=$($SHUF &lt;"$fileName" | tr  ' \011' '\012' |  head -n "$len" | tr '\n' '   ')
  echo "$LINE"
  </code></pre>
  
  <p>For my program, I need to print exactly ($len) amount of words. I am unable to achieve this. My shuffle function is working fine. The contents of the file are like this:</p>
  
  <p><code>getting and picking the
  and picking the daisies
  picking the daisies when
  the daisies when suddenly
  daisies when suddenly a</code></p>
  
  <p>Expected output after shuffling for $len = 4</p>
  
  <p><code>picking the daisies suddenly</code></p>
  
  <p>Note: The output can be any random words extracted from the file. Just needs to be of specified length $len. </p>