From owner-freebsd-questions Sun Dec 2 16:51:22 2001 Delivered-To: freebsd-questions@freebsd.org Received: from avocet.prod.itd.earthlink.net (avocet.mail.pas.earthlink.net [207.217.120.50]) by hub.freebsd.org (Postfix) with ESMTP id 0775A37B417 for ; Sun, 2 Dec 2001 16:51:16 -0800 (PST) Received: from dialup-209.245.138.197.dial1.sanjose1.level3.net ([209.245.138.197] helo=blossom.cjclark.org) by avocet.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16AhK9-0007eZ-00; Sun, 02 Dec 2001 16:51:10 -0800 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.3) id fB30p7l31045; Sun, 2 Dec 2001 16:51:07 -0800 (PST) (envelope-from cjc) Date: Sun, 2 Dec 2001 16:51:06 -0800 From: "Crist J . Clark" To: Darren Pilgrim Cc: "Gary W. Swearingen" , freebsd-questions@FreeBSD.ORG Subject: Re: Changing $IFS in a bash shell Message-ID: <20011202165106.E30433@blossom.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <3C097584.B51ECEBC@pantherdragon.org> <20011201173255.N13613@blossom.cjclark.org> <3C0AABE1.1DB4F9EC@pantherdragon.org> <20011202144947.B27117@blossom.cjclark.org> <3C0ABF94.3024DEC1@pantherdragon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3C0ABF94.3024DEC1@pantherdragon.org>; from dmp@pantherdragon.org on Sun, Dec 02, 2001 at 03:56:04PM -0800 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 , 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