[SGVLUG] bash "for" with spaces
Matt Campbell
dvdmatt at gmail.com
Mon Apr 19 21:45:31 PDT 2010
There is a nice argument to find that I use all the time...
find /media -name '*.gif' -exec makeThumb \{\} \;
another example:
find . -type f -exec mv \{\} \{\}.bk \;
Matt
> -----Original Message-----
> From: sgvlug-bounces at sgvlug.net [mailto:sgvlug-bounces at sgvlug.net] On
> Behalf Of Christopher Smith
> Sent: Monday, April 19, 2010 9:34 PM
> To: SGVLUG Discussion List.
> Cc: SGVLUG Discussion List.
> Subject: Re: [SGVLUG] bash "for" with spaces
>
> That's the point where I want to think about engaging perl, but that
> said, in the particular case I'd do:
>
> find . -type f -maxdepth 1 -print0 | grep -z -Z -l bar | xargs -0 foo
>
> --Chris
>
> On Apr 19, 2010, at 9:16 PM, "John E. Kreznar" <jek at ininx.com> wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> >>> foo "$f"
> >
> >> Where possible (and it is most often possible), the "find -print0 |
> >> xargs -0" idiom works well too.
> >
> > Very nice. Thanks! The cases where things seem to get baroque may
> be
> > when the list is the result of a computation. Example:
> >
> > for f in $(grep -l bar *) ; do foo $f ; done
> >
> > where again, file names may contain blanks. As I recall, I've been
> > driven to fiddling with the IFS shell parameter. Very messy.
> >
> > - --
> > John E. Kreznar jek at ininx.com 9F1148454619A5F08550
> 705961A47CC541AFEF13
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> > Comment: Processed by Mailcrypt 3.5.8+
> <http://mailcrypt.sourceforge.net/>
> >
> > iEYEARECAAYFAkvNKkkACgkQYaR8xUGv7xPt7wCePawIUHq+HwlDgezTA6z+p9Ou
> > gpcAn0qITqGRcZdhrOD8gL5teNJoEwv3
> > =6X47
> > -----END PGP SIGNATURE-----
> >
More information about the SGVLUG
mailing list