Skip to main content
3 of 5
no variable in the format.
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

As the others have said, the Bourne Shell doesn't have true arrays.

However, depending on what you need to do, delimited strings should suffice:

sentence="I don't need arrays because I have delimited strings"
for word in $sentence
do
  printf '%s\n' "$word"
done

If the typical delimiters don't suffice, you can also play around with setting [IFS][1] to whatever delimiter you want before the loop.

And if you need to build the array programmatically, you can just build up a delimited string. [1]: https://en.wikipedia.org/wiki/Internal_field_separator

Sildoreth
  • 2k
  • 8
  • 25
  • 42