我想测试一个变量是否有超过4位的数字,如下所示
#!/bin/bash
if [ $input has more than 4 digits ]; then
echo " * Please only 4 digits" >&2
echo""
else
the other option
fi发布于 2021-04-05 15:51:03
如果要检查变量的字符数,可以这样做.
var="foo bar"
echo "var contains ${#var} characters"
Result:
var contains 7 charactershttps://unix.stackexchange.com/questions/643616
复制相似问题