📌  相关文章
📜  如何在 shell 脚本中验证手机号码 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:55.699000             🧑  作者: Mango

代码示例3
#!/bin/bash
echo "Enter a phone number as XXXXXXXX: "
read phoneNumber
pat="^[0-9]{8}$"
while [[ ! $phoneNumber =~ $pat ]]
    do
    echo "Please enter a phone number as XXXXXXXX: "
    read phoneNumber
done
echo $phoneNumber