Skip to main content
added 2 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:


If you want to have each whitespace-separate word on its own line of output:

awk '{ for (i = 1; i <= NF; ++i) print $i }' "$myfile" 

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:


If you want to have each whitespace-separate word on its own line of output:

awk '{ for (i = 1; i <= NF; ++i) print $i }' "$myfile" 

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:


If you want to have each whitespace-separate word on its own line of output:

awk '{ for (i = 1; i <= NF; ++i) print $i }' "$myfile" 
added 149 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:


If you want to have each whitespace-separate word on its own line of output:

awk '{ for (i = 1; i <= NF; ++i) print $i }' "$myfile" 

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also:


If you want to have each whitespace-separate word on its own line of output:

awk '{ for (i = 1; i <= NF; ++i) print $i }' "$myfile" 
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The file name globbing happens on the for-line, with the expansion of $(cat $myfile), not in the echo.

When looping over the contents of a file, use read:

while IFS= read -r words; do printf '%s\n' "$words" done <"$myfile" 

See also: