#!/bin/bash echo"pleasechooseyourprofession?" PS3="pleasechoosethenumber:" functiona(){ echo"thisisfuncitona" } functionb(){ echo"thisisfunctionb" } n=0 selectvarin"worker""dock""teacher" do case$varin worker) a ;; dock) b ;; *) esac echo"thechoosenumis\$REPLYis$REPLY" echo"yourpreofessionis$var" letn++ if[$n-gt2] then break fi done原文链接:https://www.f2er.com/bash/388853.html