1
我想添加到脚本我正在写输入的限制,用户只能输入9或10个字符我这样设置,但是当我运行它时,它不按我想要的方式工作。即使我只输入一个数字,我输入的所有内容都会返回10个字符。我的代码有什么问题?允许读只接受两种长度
#!/bin/bash
#
echo "Please input numbers only"
read inputline
if read -n10 inputline
then
echo "10 chars"
else
if read -n9 inputline
then
echo "9 chars"
else
echo "invalid input length"
fi
+1,但不要忘记`y`后面的空格。 – SiegeX 2011-01-21 21:26:36