#! /bin/sh
echo "what you want to do"
echo "1:user change department"
echo "2:user change PC"
echo "3:add PC"
echo "4.delete PC"
read ANSWER
if [ $ANSWER = "1" ]; then
echo "Enter User name"
read USER1
echo "Enter PC number"
read PC1
echo "Enter previous department name"
read OLD1
echo "Enter new department name"
read NEW1
sed -i '/'"$PC1"'/d' $OLD1
echo "172.30.10."$PC1" #"$USER1 >> $NEW1
echo "Success"
elif [ $ANSWER = "2" ]; then
echo "Enter previous PC number"
read PC2
echo "Enter new PC number"
read NEW2
echo "Enter department name"
read DEPARTMENT2
sed 's/'"$PC2"'/'"$NEW2"'/' $DEPARTMENT2 > $DEPARTMENT2".temp"
cat $DEPARTMENT2".temp" > $DEPARTMENT2
rm -rf $DEPARTMENT2".temp"
elif [ $ANSWER = "3" ]; then
echo "Enter user name"
read USER
echo "Enter PC number"
read PC3
echo "Enter department name"
read DEPARTMENT3
echo "172.30.10."$PC3" #"$USER >> $DEPARTMENT3
elif [ $ANSWER = "4" ]; then
echo "Enter PC number"
read PC4
echo "Enter department name"
read DEPARTMENT4
sed -i '/'"$PC4"'/d' $DEPARTMENT4
else
echo "you had enter an invalid number"
fi
No comments:
Post a Comment