The IFS and loops

The shell has one environment variable, which is named the Internal Field Separator (IFS). This variable indicates how the words are separated on the command line. The IFS variable is, normally or by default, a whitespace (''). The IFS variable is used as a word separator (token) for the for command. In many documents, IFS can be any one of the white spaces, :, |, :, or any other desired character. This will be useful while using commands such as read, set, and for. If we are going to change the default IFS, then it is a good practice to store the original IFS in a variable.

Later on, when we have done our required tasks, then we can assign the original character back to IFS.

In the following  for_16.sh script, we are using ...

Get Learning Linux Shell Scripting - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.