Re: basic command pipe question

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

 



Les Mikesell wrote:
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.

Ah.... I see...

So the most *robust* would be:

ls -a | grep --null -iE \\.zip$ | xargs --null rm -f

That would erase all file ending with any .zip in any combination of upper and lower case characters, even if the file namehave any embedded spaces or other "special" characters.

Don

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux