Bash Shell – What is the IFS Variable?

bashshell

I was reading this thread: How to loop over the lines of a file?

What is IFS? And what is its usage in context of for-loops?

Best Answer

IFS stands for Input Internal Field Separator - it's a character that separates fields. In the example you posted, it is set to new line character (\n); so after you set it, for will process text line by line. In that example, you could change the value of IFS (to some letter that you have in your input file) and check how text will be split.

BTW, from the answer you posted the second solution is that recommended...

As @jasonwryan noticed, it's not Input but Internal. Name Input came from awk in which there is also OFS - Output Field Separator.

Related Question