谁有更好的方法帮我实现下面的代码要完成的目标

read -p "username " A
grep "^\<$A\>" /etc/passwd
B=`echo $?`
if [$B -eq 0] ;then
grep "^\<$A\>" /etc/passwd |cut -d: -f7
else
echo "your input is wrong"
fi
read -p "n or N for next"  C
D=`echo "$C" | tr 'a-z' 'A-Z'
while ["$D" == " N" ];do
read -p "username " A
grep "^\<$A\>" /etc/passwd
B=`echo $?`
if [ $B -eq 0 ];then
grep "^\<$A\>" /etc/passwd | cut -d: -f7
else
echo "your input is wrong"
fi
read -p "n or N for next " C
D=`echo "$C" | tr 'a-z' 'A-Z'
done

你可能感兴趣的:(职场,休闲,$$$)