IFS

The internal field separator: a shell variable listing the characters that word splitting and read cut text at.

In more detail

Its default is a space, a tab and a newline. Setting it just in front of a command, as in IFS== read -r key value, changes it for that command only. IFS= with nothing after the equals sign stops read from trimming leading and trailing spaces.

Example

while IFS= read -r line; do printf '%s\n' "$line"; done < file.txt

Related terms

Taught in

References

Certification courses