I have a array looking like this:
array=("(1 2 3) (123)" "2 31 (231)" "4 5 1 (451)" "(te)xt (1234)")
This array is a example. It does not look like this but its structure is the same (the strings have the same structure).
If I want to use the single strings in a select
loop I can do it like this:
select string in "${array[@]}" do # do something done
But the string in the parentheses is not for display. So I used sed to remove them:
echo "${array[@]}" | sed -r 's/ \([0-9]+\)$//g'
This did not work. Only the last parentheses were removed and the strings have been merged together. But how can I achieve the desired result which would be the same as the following example:
array2=("(1 2 3)" "2 31" "4 5 1" "(te)xt") select string in "${array2[@]}" do # do something done