I am not sure what is wrong with my bash script as it doesn't print the given flags nor it echoes them within case statement:
26 while getopts ":a:b:p:u" opts;
27 do
28 case $opts in
29 a) echo got an A flag;;
30 b) echo got an B flag;;
31 u) user=$OPTARGS echo $user;;
32 p) pass=$OPTARGS echo $pass;;
33 ?) echo I don't know what flag is this;;
34 esac
35 done
36
37 echo user: $user pass: $pass
This is how I have called it:
bash-4.3$ ./functionexample.sh -p 123 -u mona
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…