2、使用while循环或者until循环实现从命令行诗篇字符串,直到输入的字符串为句号为止;
while:
#!/bin/bash
#Prompt the user to enter a string
echo "Please input a string:"
read string
#The initial Chinese flag value
signal=0
#
while [[ "$signal" != 1 ]]
do
if [ "$string" != \. ]; then
echo "Not, Please try again!"
read string
else
signal=1
echo "Congratulation, you are right!"
fi
done
until:
#!/bin/bash
#Prompt the user to enter a string
echo "Please input a string:"
read string
#The initial Chinese flag value
signal=0
#
until [[ "$signal" = 1 ]]
do
if [ "$string" != \. ]; then
echo "Not, Please try again!"
read string
else
signal=1
echo "Congratulation, you are right!"
fi
done
