#!/bin/bash #------------------------------------------------------------------------------- # Example 3 for Bash Tips show 19: using 'read' to fill an array #------------------------------------------------------------------------------- # # Create an indexed array # declare -a readtest # # Populate it with space separated words on one line using 'echo -n' to force # that to happen # read -r -a readtest < <(for c in {A..J}{1..3}; do echo -n "$c "; done) # # The result # echo "readtest: ${#readtest[*]} elements" echo "readtest: ${readtest[*]}" exit