Field splitting in the Korn shell or POSIX shell

After performing command substitution, the Korn shell scans the results of substitutions for those field separator characters found in the IFS (Internal Field Separator) variable. Where such characters are found, the shell splits the substitutions into distinct arguments.

The shell retains explicit null arguments ("" or '') and removes implicit null arguments (those resulting from parameters that have no values).
  • If the value of IFS is a space, tab, or newline character, or if it is not set, any sequence of space, tab, or newline characters at the beginning or end of the input will be ignored and any sequence of those characters within the input will delimit a field. For example, the following input yields two fields, school and days:
  • Otherwise, and if the value of IFS is not null, the following rules apply in sequence. IFS white space is used to mean any sequence (zero or more instances) of white-space characters that are in the IFS value (for example, if IFS contains space/comma/tab, any sequence of space and tab characters is considered IFS white space).
    1. IFS white space is ignored at the beginning and end of the input.
    2. Each occurrence in the input of an IFS character that is not IFS white space, along with any adjacent IFS white space, delimits a field.
    3. Nonzero length IFS white space delimits a field.