23 lines
679 B
Bash
23 lines
679 B
Bash
#!/bin/bash
|
|
fichier=Users.csv
|
|
fichier_a_ecrire=./logins.csv #Suppression puis création du fichier
|
|
rm ./logins.csv 2> /dev/null #Redirection des erreurs
|
|
touch ./logins.csv
|
|
while read ligne
|
|
do
|
|
aecrire=""
|
|
last_name=$(echo $ligne | cut -d "," -f2 )
|
|
|
|
first_name=$(echo $ligne | cut -d "," -f1)
|
|
|
|
group=$(echo $ligne | cut -d "," -f5)
|
|
|
|
login=$(echo $first_name | cut -c1)$last_name
|
|
login=$(echo $login | tr [:upper:] [:lower:]) #la commande permet d'avoir les noms d'utilisateur en minuscule
|
|
login=$(echo $login | tr -dc [:alnum:])
|
|
passwd=$(echo $RANDOM | md5sum | head -c8)
|
|
|
|
aecrire="$login;$passwd;$first_name;$last_name;$group"
|
|
echo $aecrire >> $fichier_a_ecrire
|
|
|
|
done < $fichier |