| 您的位置:首页 > 文档 > Shell > |
文章分类热门文章 |
在等待read时如何不换行输入创建:2005-10-26 00:49:43 作者:Unlinux 来自: http://www.Unlinux.com echo " Please enter your Name:" read key 运行后: Please enter your Name: my name 光标在第二行上,如何停留咱"Please enter your Name:" 后! 在echo " Please enter your Name:"后加c echo " Please enter your Name:c" echo -n " Please enter your Name:" 根据shell不同,有不同的情况,最简单,最有效的办法是 man echo 即然是精贴,就再给它加点料--虽然关联系并不太大! 以下内容转自<永远的unix>,部份备注信息由本人增加。已在sco504下测试过。 #shell下输入字元的例子 echo "Enter a character:" stty raw #设为输入字元方式,有的系统可用stty cbreak stty -echo #设为不回显方式 readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null` #块大小为1byte,块数1 stty -raw #取消字元输入方式 stty echo #恢复回显方式 echo "The key is:$readchar" 转载自:http://www.unlinux.com/doc/shell/20051026/160.html 【评论】 【加入收藏夹】 【大 中 小】 【打印】 【关闭】 ※ 相关链接 无相关信息 |