Date: Wed, 18 Aug 2010 04:37:02 +0400 From: Anonymous <swell.k@gmail.com> To: Drew Tomlinson <drew@mykitchentable.net> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Bash Script Help - File Names With Spaces -- SOLVED Message-ID: <86bp90ycwh.fsf@gmail.com> In-Reply-To: <4C6AAAA8.9030204@mykitchentable.net> (Drew Tomlinson's message of "Tue, 17 Aug 2010 08:28:40 -0700") References: <4C6AA0FD.8000100@mykitchentable.net> <4C6AAAA8.9030204@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Drew Tomlinson <drew@mykitchentable.net> writes:
> It finally occurred to me that I needed the shell to see a new line as
> the delimiter and not whitespace. Then a simple search revealed my
> answer:
>
> O=$IFS
> IFS=$(echo -en "\n\b")
> <do stuff>
> IFS=$O
Old IFS value can be preserved by using `local' keyword or (...) braces, too.
It's a bit better than polluting global scope with temporary variable.
  $ echo -n "$IFS" | (vis -w; echo)
  \040\^I\^J
  $ for i in $(find . -type f); do echo $i; done
  ./My
  Long
  File
  Name
  ./Another
  File
  $ f() { local IFS=; eval "$@"; }
  $ f 'for i in $(find . -type f); do echo $i; done'
  ./My Long File Name
  ./Another File
  $ (IFS=; for i in $(find . -type f); do echo $i; done)
  ./My Long File Name
  ./Another File
  $ echo -n "$IFS" | (vis -w; echo)
  \040\^I\^J
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86bp90ycwh.fsf>
