http://blog.itpub.net/27181165/viewspace-775820/
An introduction to IFS
The Shell script has a variable called IFS (Internal field seprator), the internal domain delimiter. The full definition is the shell uses the value stored in IFS, which are the space, tab, and newline characters by default, to delimit words For the read and set commands, when parsing output from command substitution, and when performing variable substitution.
Shell environment variables are set, env two, where set variables can be imported into the env variable through the export tool. Where set is the display set shell variable, only valid in this shell; Env is a display set user environment variable, valid only in the current session. In other words, the SET variable contains the ENV variable, but the set variable is not necessarily an env variable. The difference between the two variables is that the scope of the variable is different. Obviously, the scope of the env variable is larger, and it can be used in Subshell.
IFS is a set variable that, when the shell handles "command substitution" and "parameter substitution", the shell, by default, is space, tab, newline, and then handles the special characters and, finally, re-assigns the variable to the value of IFS.
A simple example of two IFS
1 Viewing the value of IFS
echo "$IFS"
echo "$IFS" |od-b
0000000 040 011) 012 012
0000004
Direct output IFS is not see value, converted to binary can be seen, "040" is a space, "011" is the tab, "012" is the newline character "\ n". The last 012 is because echo defaults to wrap.
2 Applications in practice
#!/bin/bash
old_ifs= $IFS #保存原始值
Ifs= "" #改变IFS的值
...
...
ifs= $OLD _ifs #还原IFS的原始值
IFS usage in the "go" shell