I'm having a [very bad] blonde moment, and would like to know how I can have a changing variable name inside the following snippet of code:
sentence="This is a sentence containing f@#cy |3tt3r5."
for word in $sentence
do
echo $word
done
Ideally I would like to have each of the word
s in the $sentence
variable be held my a unique variable. So for example echo $word_1
would print "This" and echo $word_5
would print "containing" ... etc.
Should I be using arrays?
Q: How can I make a variable that keeps on changing i.e. word_1
word_2
.. word_n
until the for loop is complete.