#!/bin/bash
#
echo -n "Input a username of file :"
read file1
if [ -e $file1 ]
then
MAXLINE1=`wc -l $file1 |cut -d " " -f 1`
else
echo "No have username of file:"
exit
fi
echo -n "Input a passwd fo file :"
read file2
if [ -e $file2 ]
then
MAXLINE2=`wc -l $file1 |cut -d " " -f 1`
else
echo "No have username of file:"
exit
fi
if [ $MAXLINE1 -eq $MAXLINE2 ]
then
for NUM in $( seq 1 $MAXLINE1)
do
USERNAME=`sed -n ${NUM}p $file1`
PASSWORD=`sed -n ${NUM}p $file2`
id $USERNAME >& /dev/null
if [ $? -ne 0 ]
then
useradd $USERNAME
echo $PASSWORD | passwd --stdin $USERNAME
else
echo "$USERNAME alredy exists"
fi
done
else
echo "A corresponding to different user and passwd "
fi
exit