hash=""
origHash=()
iter=1
until [ "$iter" == 10 ];do
    filename="doc1"$(($iter+1))".txt"
    inputfile="doc1"$iter".txt"
    sed 's/\(.\)/\0 /g' "$inputfile" >  "$filename"
    hash=$(openssl dgst -md5 "$filename" | awk '{print $2}' | cut -c1-4)
    origHash+=($hash)
    iter=$(($iter+1))
done
echo "${origHash[*]}"
# a=$(openssl dgst -md5 doc2.txt | awk '{print $2}' | cut -c1-4)
containsElement () {
  local e match="$1"
  shift
  for e; do [[ "$e" == "$match" ]] && return 0; done
  return 1
}
iter=0
val=1
until [ "$val" == 0 ];do
    iter=$(($iter+1))
    sed -i 's\$\ \' doc1.txt
    hash=$(openssl dgst -md5 doc2.txt | awk '{print $2}' | cut -c1-4)
    containsElement "$hash" "${origHash[@]}"
    val=$?
done
echo $iter
