#!/bin/bash
for((i=1;i<=10;i++))
do
echo "user$i passwd$i">>userlist.txt
done
PASS=`which passwd`
ADDU=`which useradd`
CUT=`which cut`
while read LINES
do
USER=`echo $LINES|$CUT -d' ' -f1`
PASSWD=`echo $LINES|$CUT -d' ' -f2`
$ADDU $USER
if [ $? -ne 0 ]
then
echo "The user$i is exist,skip set password!"
else
echo $PASSWD|$PASS --stdin $USER
fi
done < userlist.txt