Skip to main content
2 of 4
edited tags
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k

Split words from `read` and store to array?

How can I take input from read and split the words up by spaces, and then put those words into an array?

What I want is:

$ read scentence
this is a senctence
$ echo $scentence[1]
this
$ echo $scentence[2]
is
(and so on...)

I'm using this to process english scentences for a text adventure.

SpecialBomb
  • 2k
  • 10
  • 28
  • 37