Computing.Net > Forums > Unix > do i need to reset IFS to default?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

do i need to reset IFS to default?

Reply to Message Icon

Name: Anthony
Date: October 30, 2002 at 02:27:20 Pacific
OS: Solaris
CPU/Ram: pentium800/256MB
Comment:

Hi,

say a file called "original" contains the following entries:
qwerty
A space
12345
secret
rm-rf*
/hello337
byehdi(#note:there's a space)

and i want to grab all the characters in those lines, including those special characters like / and space(the last 2 lines).

i set IFS to \n at the beginning of my script.
Like this:
IFS=''

and now everything's fine.

my question is:
do i need to set IFS back to its default value at the end of my script, which includes space,tab and new line? if i don't reset IFS to the default value, will other scripts be unable to use space and tab as separators?

Thanks a lot
Anthony



Sponsored Link
Ads by Google

Response Number 1
Name: jimbo
Date: October 30, 2002 at 02:45:01 Pacific
Reply:

No,
when the script is run, the shell forks another shell which then executes the script. Thus, this parameter is not passed to the parent shell.

Also, since you did not export the variable, it will not be passed to other scripts if they are called by the main script.
-jim


0

Response Number 2
Name: Anthony
Date: October 30, 2002 at 03:21:47 Pacific
Reply:

Thanks so much!

just curious, if i do want to export the variable so that other scripts can use it, what should i do? I mean which command should i use?

Thanks again
Anthony


0

Response Number 3
Name: jimbo
Date: October 30, 2002 at 03:30:10 Pacific
Reply:

in ksh/bash:
export VARIABLE=value

in sh:
VARIABLE=value ; export VARIABLE

-jim


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


log file script anyone using Teco?



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: do i need to reset IFS to default?

What hardware do I need www.computing.net/answers/unix/what-hardware-do-i-need/4044.html

how do i.... www.computing.net/answers/unix/how-do-i/1480.html

Need to grep one word, cut can't do it www.computing.net/answers/unix/need-to-grep-one-word-cut-cant-do-it/3411.html