Sys::Log

  • Archive
  • RSS

bash: Field Separator Variable

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

    • #bash
    • #tech
    • #linux
    • #unix
  • 8 months ago
  • 7
  • Permalink
  • Share
    Tweet

7 Notes/ Hide

  1. catarina-frost reblogged this from sys-log
  2. opentumble reblogged this from sys-log
  3. monzell reblogged this from sys-log
  4. loganabbott liked this
  5. sys-log posted this
← Previous • Next →

About

Avatar I am a Systems Engineer and this blog is meant to capture some of my daily activities and help teach those concepts/techniques to others.

Checkout the full version of this blog at Sys-Log.BenCane.com

Twitter

loading tweets…

Following

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr