Date: Sun, 2 Dec 2001 16:51:06 -0800 From: "Crist J . Clark" <cristjc@earthlink.net> To: Darren Pilgrim <dmp@pantherdragon.org> Cc: "Gary W. Swearingen" <swear@blarg.net>, freebsd-questions@FreeBSD.ORG Subject: Re: Changing $IFS in a bash shell Message-ID: <20011202165106.E30433@blossom.cjclark.org> In-Reply-To: <3C0ABF94.3024DEC1@pantherdragon.org>; from dmp@pantherdragon.org on Sun, Dec 02, 2001 at 03:56:04PM -0800 References: <3C097584.B51ECEBC@pantherdragon.org> <20011201173255.N13613@blossom.cjclark.org> <ausnaup7da.nau@localhost.localdomain> <3C0AABE1.1DB4F9EC@pantherdragon.org> <20011202144947.B27117@blossom.cjclark.org> <3C0ABF94.3024DEC1@pantherdragon.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 02, 2001 at 03:56:04PM -0800, Darren Pilgrim wrote:
> "Crist J . Clark" wrote:
> > > Now, how do I do the above in a script? Like this?
> >
> > Actually, after all of this trying to get a newline in IFS, I think,
> >
> > $ IFS=""
>
> This won't work, because if IFS is not defined it the shell defaults
> to tab, space, and newline as delimiters.
Did you try it? Anyway, your statement is incorrect, if I do,
$ IFS=""
IFS _is_ defined, but it is defined to be null. To get the old
defaults back, you would,
$ unset IFS
Thus speaketh the manpage,
The shell treats each character of IFS as a delimiter, and
splits the results of the other expansions into words on
these characters. If IFS is unset, or its value is
exactly <space><tab><newline>, the default, then any
sequence of IFS characters serves to delimit words. If
IFS has a value other than the default, then sequences of
the whitespace characters space and tab are ignored at the
beginning and end of the word, as long as the whitespace
character is in the value of IFS (an IFS whitespace char-
acter). Any character in IFS that is not IFS whitespace,
along with any adjacent IFS whitespace characters, delim-
its a field. A sequence of IFS whitespace characters is
also treated as a delimiter. If the value of IFS is null,
no word splitting occurs.
Note the last sentence. But I'm not sure if it is really true since it
still splits on newlines,
$ IFS=""; for dir in `find . -type f`; do echo "check: $dir"; done
Since that works as the original poster would like.
--
Crist J. Clark | cjclark@alum.mit.edu
| cjclark@jhu.edu
http://people.freebsd.org/~cjc/ | cjc@freebsd.org
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011202165106.E30433>
