First of all, sorry for the heading. I'm not sure how to place my ambition in a few words. However, from a coding/scripting standpoint it should be pretty basic. Though, I somehow fail to achieve it :/
I have a bash script that awaits a user input (either via prompt or command-line argument). As there are only a few accepted answers I check them against an array. Let's call it 'packs' for now. Each accepted answer resembles an easy and human-readable alias for something else. That would be declared in the array in the second line.
declare -a packs=('low', 'mid', 'high') declare -a packcontent=('1+1+2', '2+2+3', '3+3+4') parameters=${packcontent[xxx]}
The point where I fail is to resolve the first array with the second one. How do I get the index of the user's input in order to pass it in a variable?
Example: If the user says 'low', it should notice 'low' is the first (zeroth) element of the first array. Therefore 'parameters' should be assigned the first (zeroth) element of the second array.
parameters=1+1+2
I'm not sure if I miss an intermediate step or bash can't substitute that, but I lack any idea how I achieve that.
Hope my explanation of the issue wasn't that messy.
Kind regards!