bash: Field Separator Variable

By default when using a for loop in bash the field separator is set to a space.


[[email protected] ~]$ for x in list:like:this; do echo $x; done  

One of the cool things about bash is that you can change this by setting a simple variable $IFS

[[email protected] ~]$ IFS=":"  
[[email protected] ~]$ for x in list:like:this; do echo $x; done  
list like this

About Benjamin

Benjamin is a Infrastructure and Software Engineer. On this blog he writes about Linux, Docker, Programming as well as other Systems topics.

Learn more about Linux

If you liked this article, check out Benjamin's book: Red Hat Enterprise Linux Troubleshooting Guide. Where you can learn a lot more about troubleshooting Linux systems. This book is filled with tips and techniques he has learned over years of managing mission critical systems.