2019-05-10 11:17:57 +08:00
|
|
|
|
#!/bin/bash
|
2019-10-10 08:56:31 +08:00
|
|
|
|
|
2019-05-10 11:17:57 +08:00
|
|
|
|
# timing the data entry
|
|
|
|
|
|
|
|
|
|
if read -t 5 -p "Please enter your name:" name
|
|
|
|
|
then
|
2019-10-10 08:56:31 +08:00
|
|
|
|
echo "Hello, $name, welcome to my script"
|
2019-05-10 11:17:57 +08:00
|
|
|
|
else
|
2019-10-10 08:56:31 +08:00
|
|
|
|
#起到换行的作用
|
|
|
|
|
echo
|
|
|
|
|
#输入计数 -n1
|
|
|
|
|
read -n1 -p "Do you want to continue [Y/N]?" answer
|
|
|
|
|
case $answer in
|
|
|
|
|
Y | y) echo
|
|
|
|
|
echo "Fine, continue on..." ;;
|
|
|
|
|
N | n) echo
|
|
|
|
|
echo "OK,goodbye" ;;
|
|
|
|
|
*) echo
|
|
|
|
|
echo "OK, wrong, goodbye"
|
|
|
|
|
esac
|
|
|
|
|
echo "Sorry, this is the end of the script"
|
2019-05-10 11:17:57 +08:00
|
|
|
|
fi
|
|
|
|
|
|