I am writing my first bash script to loop through a CSV with old username to new usernames. I only read the new username to make the linux account
while read old_name new_name
do
new_name="$(tr [A-Z] [a-z] <<< $new_name)"
echo $new_name
cmd= useradd -g groupid -s /bin/ksh $new_name >> $LOGFILE 2>&1
echo password | passwd --stdin $new_name
But some users already exist and don't need a new password. Only the new users need the password.
When a user already exists I get useradd: user 'username' already exists
How can I fix this?