I tell Bash (v4.4) to give me an array, and I ask how long it is:
$ list=(one two three four)
$ echo ${#list}
3
Why are there so many more entries if I have -
in some words?
$ list=(one-two three-four)
$ echo ${#list}
7
If I ask for the items, most of them are empty. All the ones with values are first, despite the (apparently) odd behavior with -
in words.
$ for ix in $(seq 0 ${#list}); do
> echo "- ${list[$ix]}"
> done
- one-two
- three-four
-
-
-
-
-
What is going on?