Skip to main content
3 of 3
missing -a -r and quotes
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

Just

while read -ra line; 
do
    for word in "${line[@]}";
    do
        echo "$word";
    done;
done < test.txt

will split up the file word by word. Change the echo to whatever you want to do with the words.

semicolons are added so this can be put into a one-liner.

Lambert
  • 12.8k
  • 2
  • 28
  • 35