[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell script question



The generally accepted way to deal with IFS is to save the current value and restore when done:

ifs=$IFS
IFS='
'
...
IFS=$ifs

But, of course, this is a change local to the script being run, so when it exits, the change would be 'forgotten' anyway, since it's local to the sub shell that was running. The only problem could be if you need the full IFS value to process the line in some way, in the script.

Bob

Luis R Finotti wrote:
Mario 'BitKoenig' Holbe wrote:

Andras Lorincz <andras.lorincz@gmail.com> wrote:

ENTRY=3D$(cat input_file)
for I in $ENTRY



while read i; do
    echo "$i"
done < input_file


regards
   Mario


And if the spaces give you trouble, add

---------
IFS='
'
---------

That's just a "newline" between the single quotes. This changes the "input field separator" to a new line and not a space. (The default is space, tab, newline, I think.) You can change it back later if you need.

HTH,

Luis





Reply to: