我有以下脚本
echo "please enter user name: "
read USER_NAME
while [ ! "$USER_NAME" ]
do
echo "User name can't be empty please re-enter: "
read USER_NAME
done
如何使用命令行上的命令执行相同操作?
答案1
您可以使用while [ "$USER_NAME" == "" ] ...
或while [ -z $USER_NAME ]
。
我有以下脚本
echo "please enter user name: "
read USER_NAME
while [ ! "$USER_NAME" ]
do
echo "User name can't be empty please re-enter: "
read USER_NAME
done
如何使用命令行上的命令执行相同操作?
您可以使用while [ "$USER_NAME" == "" ] ...
或while [ -z $USER_NAME ]
。