basic command pipe question

Les Mikesell lesmikesell at gmail.com
Mon Jun 19 04:13:52 UTC 2006


On Sun, 2006-06-18 at 22:47, Don Russell wrote:

> I see how
>     ls | grep -i '\.zip$' | xargs rm
> is the preferred method of the three above....
> 
> But... in reading the man pages for xargs, it says this may be 
> problematic if the file name contain blanks.

If you don't mind directory recursion:

find -iname '*.zip' -print0 |xargs -0 rm


> What's your opinion of
>     rm *.[zZ][iI][pP]
> 
> Although, if I understand properly what's happening here, the pipe 
> solution allows files to be erased as they are found in the filelist, 
> while the gobbing method first requires that all files that match be 
> found, then each command is executed one after another. 

No, this is the most efficient if it fits the command line buffer.
The shell expands the file list and gives the expanded command
line to one invocation of rm.

-- 
  Les Mikesell
   lesmikesell at gmail.com





More information about the fedora-list mailing list