Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #1604

Re: calling script function on output of find

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From dave.gma+news002@googlemail.com.invalid (Dave Gibson)
Newsgroups comp.os.linux.misc
Subject Re: calling script function on output of find
Date Tue, 05 Jul 2011 19:17:29 +0100
Organization A noiseless patient Spider
Lines 27
Message-ID <p21ce8x6p2.ln2@perseus.wenlock-data.co.uk> (permalink)
References <97g5odFp36U1@mid.individual.net>
Injection-Info mx04.eternal-september.org; posting-host="8VtvICwVZ/SW30fPThMPBQ"; logging-data="5859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196cNW0/B8JnxZryE/Do6mv"
User-Agent tin/1.9.6-20101126 ("Burnside") (UNIX) (Linux/2.6.36-1 (i686))
Cancel-Lock sha1:/Hy+neBTl7mC/C4zC9vFqtx9ybg=
Xref x330-a1.tempe.blueboxinc.net comp.os.linux.misc:1604

Show key headers only | View raw


John Stumbles <john.stumbles@ntlworld.com> wrote:
> I have
> 
> for f in `find $SOURCE_DIR -type f -size +0`; do 
>    process_file "$f"
> done
> 
> where process_file is a function within the same bash script.
> 
> However if $SOURCE_DIR has spaces in the name 
> e.g. "/foo/bar/space in name"
> the script tries to process_file on parts of the pathname
> i.e.
>  process_file /foo/bar/space 
>  process_file in
>  process_file name
> 
> This seems to be a limitation of the "for f in ..." construct and I 

Captured output (`...`) is subject to word splitting.

> should probably be doing something else - but what?!

find "$SOURCE_DIR" -type f -size +0 |
while IFS= read -r f ; do
  process_file "$f"
done

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-05 10:01 +0000
  Re: calling script function on output of find Joe Makowiec <makowiec@invalid.invalid> - 2011-07-05 10:20 +0000
    Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-09 12:04 +0000
  Re: calling script function on output of find dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2011-07-05 19:17 +0100
    Re: calling script function on output of find unruh <unruh@wormhole.physics.ubc.ca> - 2011-07-05 20:01 +0000
      Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-09 12:21 +0000
        Re: calling script function on output of find Bill Marcum <bill@lat.localnet> - 2011-07-12 19:43 -0400
          Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-16 00:26 +0000
    Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-09 12:48 +0000
      Re: calling script function on output of find dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2011-07-09 19:52 +0100
  Re: calling script function on output of find Chris Davies <chris-usenet@roaima.co.uk> - 2011-07-07 09:37 +0100
    Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-08 10:02 +0000
      Re: calling script function on output of find Chris Davies <chris-usenet@roaima.co.uk> - 2011-07-08 16:48 +0100
        Re: calling script function on output of find unruh <unruh@wormhole.physics.ubc.ca> - 2011-07-08 17:46 +0000
          Re: calling script function on output of find Chris Davies <chris-usenet@roaima.co.uk> - 2011-07-08 20:56 +0100
            Re: calling script function on output of find unruh <unruh@wormhole.physics.ubc.ca> - 2011-07-08 21:14 +0000
              Re: calling script function on output of find Chris Davies <chris-usenet@roaima.co.uk> - 2011-07-09 11:17 +0100
        Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-09 12:51 +0000
          Re: calling script function on output of find Chris Davies <chris-usenet@roaima.co.uk> - 2011-07-10 10:45 +0100
            Re: calling script function on output of find John Stumbles <john.stumbles@ntlworld.com> - 2011-07-10 23:14 +0000

csiph-web