Musings and Mutterings through the Machines

  • RSS
  • About Me
  • Resources
  • Projects
  • Professional Resume
  • Social
  • Blog

bash: Field Separator Variable

Published: Wed 21 September 2011
By rilindo

In Blog.

tags: bash linux tech unix

sys-log:

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

Example:

[bcane@bcane \~]\$ for x in list:like:this; do echo \$x; done
list:like:this

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

[bcane@bcane \~]\$ IFS=:
[bcane@bcane \~]\$ for x in list:like:this; do echo \$x; done
list like this

Proudly powered by Pelican, which takes great advantage of Python.

The theme is by Smashing Magazine, thanks!