Dynamic case statement in bash
- by infra.user
Hi folks,
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 contents
red
green
blue
In this scenario, the output can change at any time.
I'm trying to then execute different logic if a value is included in this awk output.
So if the data above is in $list, then I'd conceptually like to do something like:
case "${my_var}" in
$list)
.....
something_else)
.....
esac
I'm trying to use this to build a dynamic custom tab completion function (see http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2 for some background).
Any ideas?
Thanks.