Hey Iam trying to create new users from textfile and set passwwords for them. I wrote this script
#! /bin/bash
userfile=/home/kancelaria-2p/Desktop/uzivatelia.txt
number=1234
username=$(cat $userfile | tr '[:upper:]' '[:lower:]')
password="$username$number"
for user in $username
do
sudo useradd $$user
echo "$user:$password" | sudo chpasswd
done
Unfortunately all I get is theese errors
chpasswd: line 2: missing new password
chpasswd: line 3: missing new password
chpasswd: line 4: missing new password
chpasswd: line 5: missing new password
chpasswd: line 6: missing new password
chpasswd: line 7: missing new password
chpasswd: line 8: missing new password
chpasswd: line 9: missing new password
chpasswd: line 10: missing new password
Can you help me fix it?