I am trying to create a user from a a text file called names.txt
(first and second field will be comment, third field will be username and forth field will be password)
Jessica Brown,jessicabrown,id0001
James Santos,jamessantos,id0002
This is what I have so far, but it is not working and I have a feeling I can do it a shorter way but can't figure it out.
user_name=$(cat names.txt | cut -d, -f3)
password1=$(cat names.txt | cut -d, -f4)
comment1=$(cat names.txt | cut -d, -f1 -f2)
user_name2=$(cat names.txt | cut -d, -f3)
password2=$(cat names.txt | cut-d, -f4)
comment2=$(cat names.txt | cut -d, -f1 -f2)
useradd "$user_name" -p "$password1" -c "$comment1"
useradd "$user_name2" -p "$password2" -c "$comment2"