I\'m trying to figure out how to create a dynamic case statement in a bash script.
For example, let\'s say I have the output of an awk statement with the following c
You can create a dynamic case statement in bash by doing the following:
1) ensure the list is PIPE (|) seperated. IE. red|green|blue
2) wrap your case statement in an eval
For example:
valid="red|green|blue"
eval "case \"$choice\" in
$valid)
echo do something good here
;;
*)
echo invalid colour
;;
esac"
This works for simple variable processing, I can not guarantee this will work in all cases.