Software >> OS >> Unix >> Solaris >> How to set the Internal Field Separator (IFS) to modify the behaviour of for loops when processing text files

# IFS='character'

 

examples

# IFS='\n'
# for f in `cat list.txt`;do echo $f;done;
abc def geh.txt
abc def.txt

# IFS=' '
# for f in `cat list.txt`;do echo $f;done;
abc
def
geh.txt
abc
def.txt

 Note:

following also tested to work (bash specific??)

# IFS=$'\n'