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

Just

while read -ra line; 
do
    for word in $"${line[@]};";
    do
        echo $word;"$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.

Just

while read 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.

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.

added 121 characters in body
Source Link
Lambert
  • 12.8k
  • 2
  • 28
  • 35

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

while read 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.

Just while read 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.

Just

while read 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.

Source Link
Lambert
  • 12.8k
  • 2
  • 28
  • 35

Just while read 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.