Files
hpr_website/www/eps/hpr2739/hpr2739_bash19_ex3.sh

25 lines
560 B
Bash
Raw Permalink Normal View History

2025-10-28 18:39:57 +01:00
#!/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