Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Per Greg's Wiki the IFS variable is used:

  • In the read command, if multiple variable-name arguments are specified, IFS is used to split the line of input so that each variable gets a single field of the input.
  • When performing WordSplitting on an unquoted expansion, IFS is used to split the value of the expansion into multiple words.
  • When performing the "$*" or "${array[*]}" expansion,the first character of IFS is placed between the elements in order to construct the final output string.
  • When doing "${!prefix*}", the first character of IFS is placed between the variable names to make the output string.
  • IFS is used by complete -W under programmable completion

So my question is, why should IFS have to come into play in variable assignment? Per the below, bash is applying word-splitting on the string on the right(a:b:c:d).

$ IFS=: s=a:b:c:d
$ echo $s
a b c d
share|improve this question
up vote 4 down vote accepted

It doesn't. You need to quote properly. Word splitting is applied to unquoted expansions according to the value of IFS. The problem is your echo command, not the assignment.

 $ ( IFS=: s=a:b:c:d typeset -p s )
declare -- s="a:b:c:d"
share|improve this answer
got it..thank you – iruvar Dec 8 '12 at 5:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.