On 7/7/16 3:01 PM, Todd Merriman wrote: > Bash Version: 4.2 > Patch Level: 46 > Release Status: release > > Description: > IFS=' ' # TAB > program_outputting_tab_delimited_fields | > while read -r FLD1 FLD2 FLD3 FLD4 > do > echo field1=$FLD1 > echo field2=$FLD2 > echo field3=$FLD3 > echo field4=$FLD4 > done > > Repeat-By: > If any fields are empty, the data is read into the preceding field. > In other words, if in the example FLD3 is empty, FLD4 is read into > FLD3. If FLD2 and FLD3 are empty, FLD4 is read into FLD1.
This is the correct behavior. Sequences of multiple whitespace characters delimit fields, as long as those whitespace characters are in $IFS. This is explained in the man page, in the paragraph that begins: "The shell treats each character of IFS as a delimiter..." It reads, in part, "A sequence of IFS whitespace characters is also treated as a delimiter." The paragraph explains what IFS whitespace characters are. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/