How to set IFS variable in bash 

>I need to do the following
>
>for x in $(cat filename)
>do
>    do anything here with the single lines of the file
>done
>
>This works well if there are no spaces in the lines.
>
>How can i set the IFS variable to separate the input only in case of
>newlines.
>
>but this starts a new shell and I loose the value of the variables I set in
>the loop when I come back ( or is there a way to give them back ?

I have found the solution using goggle at http://www.linux.ie/pipermail/ilug/1999-December/010019.html

Andreas

How to set IFS variable in bash 

Beware, the IFS variable is dangerous and should be removed from all vendor distributions. (Garfinkle & Spafford, 1993)

Why do you need to re-set it and is there another way you can solve your problem ?

Many programs will start behaving strangely if it's not what they (you) expect it to be . . . (BASH being one of them).

# possible solution . . .
IFSTEMP=${IFS}
IFS=^M
# put as little code as possible in here . . .
#
IFS=${IFSTEMP}

documented on: 2000.09.04 Mon 14:39:21