title: Random Password Generator Bash
body: <p>I am trying to make a password generator that generates a password between 8-16 characters. It also has to contain a digit and lower and uppercase letters, as well as only one special character that is randomly placed in the string when being generated. </p>
  
  <p>At the moment, my code will sometimes give me a password that does not meet the requirements eg. <code>AOKOKKK@1</code> (no lowercase letters) In addition, I also need help to make it so that the special symbol only appears once in the password. How can I fix this?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>length=$[ 8 +$[RANDOM % 16]]
  
  char=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ! @ \# $ % ^ \&amp;)
  
  max=${#char[*]}
  for ((i = 1; i &lt;= $length ; i++))do
  
  let rand=${RANDOM}%${max}
  password="${password}${char[$rand]}"
  done
  echo $password
  </code></pre>