IFS
suggest changeContains the Internal Field Separator string that Bash uses to split strings when looping, and so on. The default value is space, tab, and newline — the characters themselves, not the two-character strings \n and \t. Changing IFS lets you split strings on different characters:
IFS=","
INPUTSTR="a,b,c,d"
for field in ${INPUTSTR}; do
echo $field
done
The output of the above is:
a
b
c
d
Notes:
- This is responsible for the phenomenon known as word splitting.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents