basic command pipe question

Ingemar Nilsson init at pdc.kth.se
Thu Jun 22 14:41:38 UTC 2006


Todd Zullinger <tmz at pobox.com> writes:

> 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;

Why not use

find -iname "*.zip" -exec rm {} \;

I'm quite sure that this deals with spaces just fine. The {} is replaced
with the file name for each file found by find, and the \; indicates the
end of the command given by -exec.

Regards
Ingemar




More information about the fedora-list mailing list