The problem is not
IFS's contents, which is used as a field separator between the individual fields. Your
read is missing the line terminator, usually <LF> (= \n = 0x0A = ^J) which is not
printfed. So
read waits for it but runs into an EOF / EOT (as stdin terminates),
discards the data read so far, and breaks out of the loop having
unprocessed data in the variable(s) (Thanks to MadeInGermany's post#5 for mentioning that). You can
- add a linefeed <LF> to the
printf command
- switch
read to use a different line terminator (which still needs to be
printfed).
man bash:
Quote:
read
-d delim
The first character of delim is used to terminate the input line, rather than newline.
sea's proposal will set
IFS to " ", "\", and "n", split input on any collection of those, and eliminate them from input. Set
IFS like
IFS=$' \n' to make it <space> and <line feed>.