Я пытаюсь создать разных пользователей из файла CSV в bash. Это мой код до сих пор:
#create arrays usernames and password
groups=(`cut -d: -f 1 "$filein"`)
usernames=(`cut -d: -f 3 "$filein" | tr [A-Z] [a-z] |awk '{print substr($1.$2}'`)
password=(`cut -d: -f 4 "$filein"`)
#creates the user accounts, adds them to groups, and sets passwords
#then once account is created
#checks if the group exists, if not then creates it
for group in ${groups[*]}
do
grep -q "^$group" /etc/group ; let x=$?
if [ $x -eq 1 ]
then
groupadd "$group"
fi
done
#creates the user accounts, adds them to groups, and sets passwords
#then once account is created
x=0
created=0
for user in ${usernames[*]}
do
useradd -n -c ${usernames[$x]} -g "${groups[$x]}" $user 2> /dev/null
chpasswd "$user" > /dev/null
if [ $? -eq 0 ]
then
let created=$created+1
fi
По какой-то причине, когда я запускаю файл, я получаю эту ошибку, даже пошёл разрешить мне добавить группу пользователей: 'Q123456, Боб, Боб, QwertY1' недопустимое имя группы groupadd: 'Q236578, Jane, Jane, AzertY2' не является допустимым именем группы. Любая помощь будет принята с благодарностью. Спасибо