${line}

"

done

IFS=$OLD_IFS

Be aware that changing IFS in the scripts shown above only affects IFS within the context of those scripts. If you want to change IFS in the context of your running bash shell and all sub-shells (and other child processes) that it spawns then you will need to export it like this:

IFS=$'

'

export IFS

– or –

export IFS=$'

'

And if you want this change to be system wide (not recommended) then you need to put this into /etc/environment or /etc/profile, or whatever is appropriate for your system configuration.

References

http://mywiki.wooledge.org/BashFAQ/001

http://mywiki.wooledge.org/BashFAQ/005

http://tldp.org/LDP/abs/html/internalvariables.html

http://www.gnu.org/software/bash/manual/bashref.html#Word-Splitting

Disclaimer:

Please keep in mind that the references listed above know WAY MORE than me. As of this post I’ve only been bash scripting for about three months and I only do it on occasion – like maybe once every three weeks – to solve some IT or embedded development issue. My posts are only meant to provide quick [and sometimes dirty] solutions to others in situations similar to mine. If you really want to be good at bash scripting then spend some quality time with the official documentation or a good book.