I want to write a script in CentOs 7 that creates a new user for every CSV file row.
My csv file looks like this:
username;firstname;lastname;password
username2;firstname2;lastname2;
...
...
First column is the username, second is the first name, third is the last name and last column stands for password. If there isn't a password, it creates a user with some default value.
My code:
#!/bin/bash
export IFS=";"
cat users.csv | while read username name surname password; do
useradd "$username" -c "${name} ${surname}" -p "$password"
done
How do I create users from each column?