title: Bash dictionary attack - prints whole dictionary rather than runs process
body: <p>My bash dictionary attack function will select the first word from the dictionary and see if it compares with my hash but then stop, and if it doesn't, it will search the whole dictionary but not actually return the password. When it stops the password is always "1080", no matter what the hash is</p>
  
  <p>I don't understand what's happening, but I've researched quite a lot </p>
  
  <pre><code>dict_attack(){
  TARGET_HASH=$1
  while read WORD; do
      WORD_HASH=$(echo $WORD | sha256sum | awk '{print $1}')
      if [ "$WORD_HASH"=="$TARGET_HASH" ]; then
              echo "Guessed it!"
              echo "Password is : $WORD"
              exit
      fi
  done &lt; /usr/share/dict/linux.words
  </code></pre>
  
  <p>Here is the call in the rest of the script.</p>
  
  <pre><code>dict_attack $1
  </code></pre>