TECHIES WORLD

For Techs.... Techniques.... Technologies....

CpanelLinux

How to set newline as delimiter in bash 'for' loop

By default whitespace is the delimiter in for loop. We can set custom delimiters using IFS (Internal Field Separator) option.

For setting newline as delimiter we need to specify the same using IFS before starting the for loop.

IFS=$'\n'
for (condition)
do
commands
done
That's all....

Leave a Reply