Date: Fri, 14 Oct 2005 13:12:37 -0700 From: Drew Tomlinson <drew@mykitchentable.net> To: Will Maier <willmaier@ml1.net> Cc: freebsd-questions@freebsd.org Subject: Re: Help With 'for' Loop Message-ID: <43501135.2010106@mykitchentable.net> In-Reply-To: <20051014200526.GP29905@localdomain> References: <435007F3.8000106@mykitchentable.net> <20051014200526.GP29905@localdomain>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/14/2005 1:05 PM Will Maier wrote: >On Fri, Oct 14, 2005 at 12:33:07PM -0700, Drew Tomlinson wrote: >[...] > > >>Yet 'echo $i' only returns "/multimedia/Pictures/1998", stopping >>at the first space. Is it possible to get 'i' to represent the >>whole string that 'find' returns? If so, how? >> >> > >Bourne-style for loops use <space> as the delimiter by default. To >change this behavior, modify the IFS variable (which is mentioned >but not explained in the sh manpage): > > $ OLDIFS=$IFS # probably want to remember this value > $ IFS=: > $ export $IFS > $ for i in $PATH; do > echo $i > done > /home/will/bin > /usr/local/sbin > /usr/local/bin > /usr/sbin > /usr/bin > /sbin > /bin > /usr/X11R6/bin > /opt/ > /usr/games/ > $ IFS=$OLDIFS # set it back to normal > $ export $IFS > $ for i in $PATH; do > echo $i > done > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/opt/:/usr/games/ > > Thanks for this explanation. I will look at the sh man page. Cheers, Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, & More! http://www.alchemistswarehouse.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43501135.2010106>