"#!/bin/bash\n\n# 定义函数,用于获取用户输入参数\nget_input() {\n\tread -p "请输入参数(1或2): " input\n\t# 判断输入是否为1或2,如果不是则重新获取输入\n\twhile [[ "$input" != "1" && "$input" != "2" ]]; do\n\t read -p "输入有误,请重新输入参数(1或2): " input\n\t\tdone\n\t# 输出最终输入参数\n\techo "您输入的参数为: $input"\n}\n\n# 调用函数获取用户输入\nget_input\n"\


原文地址: https://www.cveoy.top/t/topic/p04J 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录