Date: Fri, 14 Oct 2005 15:05:26 -0500 From: Will Maier <willmaier@ml1.net> To: freebsd-questions@freebsd.org Subject: Re: Help With 'for' Loop Message-ID: <20051014200526.GP29905@localdomain> In-Reply-To: <435007F3.8000106@mykitchentable.net> References: <435007F3.8000106@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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/ -- o--------------------------{ Will Maier }--------------------------o | jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net | | \.........wcmaier@cae.wisc.edu | \..........wcmaier@cae.wisc.edu | *------------------[ BSD Unix: Live Free or Die ]------------------*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051014200526.GP29905>