红联Linux门户
Linux帮助

如何在SHELL程序中实现‘按任意键继续’

发布时间:2011-12-22 13:30:36来源:红联作者:hlp4593
我在做一个魔幻盒子 (长方形) 其中一个是在按下某按键的情况下四边形的颜色可变比如按下1 ,长方形的四条边变成红色,按下2变成其他颜色
while:
do
printf"press any key to continue:"
case "$c" in
0) col=0;;
1) col=1;;
2) col=2;;
3) col=3;;
4) col=4;;
5) col=5;;
6) col=6;;
7) col=7;;
*) echo"wrong"
esac
done
在这个基础上是按键可以起作用
从外部读入一个数据控制变化。
文章评论

共有 4 条评论

  1. hlp4593 于 2011-12-26 20:28:49发表:

    谢谢啊

  2. huangyandong 于 2011-12-23 21:55:42发表:

    把 printf"press any key to continue:"改成 read -p "press any key to continue" c

  3. huangyandong 于 2011-12-23 21:55:32发表:

    while (( 1 ))
    do
    read -p "press any " c
    case "$c" in
    0) col=0;;
    1) col=1;;
    2) col=2;;
    3) col=3;;
    4) col=4;;
    5) col=5;;
    6) col=6;;
    7) col=7;;
    *) echo "wrong" ;;
    esac
    done

  4. huangyandong 于 2011-12-23 21:52:23发表:

    把 printf"press any key to continue:"改成 read -p "press any key to continue" c