说明 为变量设置默认值 脚本 #!/bin/bash read -p "请输入用户名:" n useradd $n read -p "请输入密码:" p echo "${p:-12345}" | passwd --stdin $n #12345是新建用户密码的初值