【发布时间】:2020-04-13 10:53:09
【问题描述】:
如果标题不具体,我很抱歉,但我需要一些帮助: 我正在尝试做一个小猜谜游戏,我正在尝试实现一个提示
#!/bin/bash
echo "what comes once in a minute, twice in a moment, but never in a thousand years?
(lowercase)"
read input
if [ $input = "m" ] ; then
clear
echo "correct"
sleep 4.4
clear
elif [ $input = "hint" ] ; then
clear
echo "its a letter" #what do i do so that after it prints "its a letter"
clear #it comes back to the beginning of the if statement
else
clear
echo "incorrect"
sleep 4.4
clear
fi
例如:我运行脚本
-它将打印what comes once in a minute, twice in a moment, but never in a thousand years?
-i 回复hint 并在给出提示后返回等待我输入答案
【问题讨论】:
-
请学会缩进你的代码。
-
使用无限循环
-
@Guack :您还应该删除第一行中
#!之前的空格。
标签: bash loops if-statement