title: How to create a list of subdirectories in a list of directories in bash
body: <p>First of all, I'm not allowed to use more for or while loops because this is task for university.</p>
  <p>I have the following:</p>
  <pre><code>for i in {00..20}
  do  
      users=( $(ls &quot;$dir&quot;/&quot;$1&quot; | grep &quot;room_${i}_*&quot; | cut -d '.' -f 1 | cut -d '_' -f 3-4 | sort | uniq) )
      cd &quot;$dir&quot;/&quot;$2&quot;/r&quot;${i}&quot; || exit
      mkdir -p &quot;${users[@]}&quot;/{MP4,MOV,AVI,WMV,MKV}
  done
  
  </code></pre>
  <p>I have bunch of videos named room_XX_user_Y.ext, where XX is a number between 00 and 20, Y is unknown and ext is one of {MP4,MOV,AVI,WMV,MKV}. So, I have to move the file to /rXX/user_Y/ext/ and I have to create all of them except rXX (r stands for room). Every user has a video with this extensions.</p>
  <p>I'm able to do everything except creating all the {MP4,MOV,AVI,WMV,MKV} directories inside the user_Y directory. If the users for a room are a, b, c and d, the directories for extensions will only be created on the user_d directory.</p>
  <p>Thank you all.</p>