What does the bash operator <<< mean, as inside the following code block? And how come does $IFS remain to be a space, not a period?
LINE="7.6.5.4"
IFS=. read -a ARRAY <<< "$LINE"
echo "$IFS"
echo "${ARRAY[@]}"
What does the bash operator <<< mean, as inside the following code block? And how come does $IFS remain to be a space, not a period?
LINE="7.6.5.4"
IFS=. read -a ARRAY <<< "$LINE"
echo "$IFS"
echo "${ARRAY[@]}"
The reason that IFS is not being set is that bash isn't seeing that as a separate command... you need to put a line feed or a semicolon after the command in order to terminate it:
but
I'm not sure why doing it the first way wasn't a syntax error though.
It redirects the string to stdin of the command.
Variables assigned directly before the command in this way only take effect for the command process; the shell remains untouched.
From
man bash
The.
on the IFS line is equivalent tosource
in bash.Update: More from
man bash
(Thanks gsklee, sehe)yet more from
man bash