到目前为止,我有这个。
#! /bin/bash
file=/home/userlist.txt
while read -r username directory full
do
IFS=':'
PASSWORD=$(pwgen -1 -s 16)
useradd -s /bin/bash -d $directory -c $full -m -p "$PASSWORD" "$username"
echo "$username $directory $full ---- $PASSWORD" >> /home/created
done
似乎无法添加用户。读取文件。我知道这是因为created.txt并显示了它。
答案 0 :(得分:0)
#!/bin/bash
file=userlist.txt
IFS=':'
while read username directory full; do
PASSWORD=$(pwgen -1 -s 16)
useradd -s /bin/bash -d $directory -c $full -m -p "$PASSWORD" "$username"
echo "$username $directory $full ---- $PASSWORD" >> created
done < $file