basic command pipe question
Todd Zullinger
tmz at pobox.com
Sun Jun 18 22:23:12 UTC 2006
-----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-----
More information about the fedora-list
mailing list