1753887 Members
7619 Online
108809 Solutions
New Discussion юеВ

IFS - Set back to space

 
SOLVED
Go to solution
Simpson
Occasional Advisor

IFS - Set back to space

Hello,

I have a (KSH) script that interprets different input squences and processes them. The first of which is a CSV so I have set IFS to comma with:
IFS=,

Now later in my script I am reading input in from a grep command and would like to:
grep $i $file |read var1 var2 var3 ....

How do I set my IFS back to spaces. Here is what I have tried thus far:
IFS=
IFS=""
IFS=" "
IFS=''
IFS=' "

Any help would be greatly appreciated.
Mike
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: IFS - Set back to space

Hi Mike:

Simply do:

OLDIFS=${IFS}
IFS=":" #...or whatever...
IFS=${OLDIFS}
...

Regards!

...JRF...
Simpson
Occasional Advisor

Re: IFS - Set back to space

That was PERFECT. thank you so very very much. Great responce and timely.
James R. Ferguson
Acclaimed Contributor

Re: IFS - Set back to space

Hi (again) Mike:

By the way, the default shell IFS is a combination of space, tab, and newline which is why you failed to restore the behavior you thought your were.

Regards!

...JRF...