Skip to main content
deleted 24 characters in body
Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42

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 can use delimited strings"
for word in $sentence
do
  printf '%s\n' "$word"
done

If the typical delimiters (space, tab, and newline) don't suffice, you can also play around with setting [IFS][1]set IFS 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

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 can use 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

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 can use delimited strings"
for word in $sentence
do
  printf '%s\n' "$word"
done

If the typical delimiters (space, tab, and newline) don't suffice, you can set IFS 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.

added 3 characters in body
Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42

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 havecan use 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

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

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 can use 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

no variable in the format.
Source Link
Stéphane Chazelas
  • 584.5k
  • 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 "$word\n"'%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

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 "$word\n"
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

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

added 4 characters in body
Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42
Loading
Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42
Loading