On Sat, 1 Apr 2023 19:44:10 -0400 Saint Michael <vene...@gmail.com> wrote:
> There is an additional problem with IFS and the command read > > Suppose I have variable $line with a string "a,b,c,d" > IFS=',' read -r x1 <<< $line > Bash will assign the whole line to x1 > echo $x1 > line="a,b,c,d";IFS=',' read -r x1 <<< $line;echo $x1; > a,b,c,d > but if I use two variables > line="a,b,c,d";IFS=',' read -r x1 x2 <<< $line;echo "$x1 ---> $x2"; > a ---> b,c,d > this is incorrect. If IFS=",", then a read -r statement must assign the No it isn't. > first value to the single variable, and disregard the rest. No it musn't. Read https://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html and pay particular attention to the definition of what must happen where there are fewer vars (names) than fields encountered. -- Kerin Millar