SyntaxFix
Write A Post
Hire A Developer
Questions
Did you try just passing the string variable to a for loop? Bash, for one, will split on whitespace automatically.
for
sentence="This is a sentence." for word in $sentence do echo $word done
This is a sentence.