Re: basic command pipe question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Mohler wrote:
> How about something like:
> 
> for i in $(find -iname "*.zip"); do rm  $i; done;
> 
> Not pretty but that's roughly what I used to move a bunch of JPEGs
> with .jpg and .JPG extentions...

One thing that would bite you on a for loop like this is files with
spaces in them.  Using a while loop is one way to get around that if
you want to do the rm one at a time for whatever reason:

find -iname "*.zip" | while read i; do rm "$i"; done;

At least, that's the way I tend to do it when I'm dealing with files
which contain spaces.  Using xargs, you can use the -0 option to
handle files with spaces in them.  (I really ought to use of xargs
more often. :)

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
We never reflect how pleasant it is to ask for nothing.
    -- Seneca

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkSV0lAmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1ocCACfZUq8OlFtsc/a1X9U+KgK2fQMfS0Anj4pw/2l
s0eX/+x9EIAMZV303imR
=h4N5
-----END PGP SIGNATURE-----


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux