shell - Case statement not working -
its part of program,
output="$(./t1)" // output=5 echo $output // displays 5 if test $output -eq 5 echo "five" // if statement works , displays 'five' fi case $output in **// case not working , giving default value** 1) echo "one" ;; 2) echo "two" ;; 3) echo "three" ;; 4) echo "four";; 5) echo "five";; *) echo "wrong choice" ;; esac // output wrong choice though works proper in if statement is there mistake in bash script? please help.
this works me:
output=$(./t1) echo $output if test $output -eq 5; echo "five"; fi case $output in 1) echo "one" ;; 2) echo "two" ;; 3) echo "three" ;; 4) echo "four";; 5) echo "five";; *) echo "wrong choice" ;; esac when had " around $(./t1) result string, not numeric value. worked test, not case. has couple of missing ; in post , // not valid comments in bash.
Comments
Post a Comment