Вы можете сохранить сгенерированный пароль в переменной и записать его в два файла:
Например:
# initialize (truncate) output files
> clear.txt
> hashed.txt
cut -d: -f1 pw.txt | while read -r user; do
# generate a hash from a random number
hash=$(openssl passwd $RANDOM)
# use the first 8 letters of the hash as the password
pass=${hash:0:8}
# write password in clear formats to one file, and hashed in another
echo "$user:$pass" >> clear.txt
echo "$user:$(openssl passwd $pass)" >> hashed.txt
done