I have an array and I want to get the unique 2nd membersbash doesn't really have 2-dimensional array so I've defined it this way, using :: as the separator of the two elements:ruby_versions=('company-contacts::1.7.4''activerecord-boolean-converter::1.7.4''zipcar-rails-core::1.7.4''async-tasks::1.7.13''zc-pooling-client::2.1.1''reservations-api::1.7.4''zipcar-auth-gem::1.7.4''members-api::1.7.4''authentication-service::1.7.4''pooling-api::2.1.1')I can iterate successfully thru the 2nd elements of the array with:rvm list > $TOP_DIR/local_ruby_versions.txtfor repo in ${ruby_versions[@]}do  if grep -q ${repo##*::} $TOP_DIR/local_ruby_versions.txt    then    echo ruby version ${repo##*::} confirmed as present on this machine  else    rvm list    echo *** EXITING SMOKE TEST *** - not all required ruby versions are present in RVM    echo Please install RVM ruby version: ${repo##*::} and then re-run this program    exit 0  fidoneecho AThe only downside is that it repeats the action when the ruby version is the same (which is usually the case), so I getruby version 1.7.4 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 1.7.13 confirmed as present on this machineruby version 2.1.1 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 1.7.4 confirmed as present on this machineruby version 2.1.1 confirmed as present on this machinewhen I haveruby_versions=(  'company-contacts::1.7.4'  'activerecord-boolean-converter::1.7.4'  'zipcar-rails-core::1.7.4'  'async-tasks::1.7.13'  'zc-pooling-client::2.1.1'  'reservations-api::1.7.4'  'zipcar-auth-gem::1.7.4'  'members-api::1.7.4'  'authentication-service::1.7.4'  'pooling-api::2.1.1')How can I make it so it only does the check for 1.7.4 and 2.1.1 once ?i.e. How can I turn my array selection into (1.7.4 2.1.1)The actual repo names can be ignored in this context.
How to select unique array values?
bash;shell script;array;ruby;rvm
You could use an associative array:declare -A versionsfor value in ${ruby_versions[@]}; do    versions[${value##*::}]=1doneprintf %s\n ${!versions[@]}1.7.41.7.132.1.1Or with a pipeline:mapfile -t versions < <(printf %s\n ${ruby_versions[@]} | sed 's/.*:://' | sort -u)printf %s\n ${versions[@]}1.7.131.7.42.1.1