Re: basic command pipe question

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

 



Todd Zullinger writes:

Don Russell wrote:
I need some basic CLI help. :-) I've googled, and read, and I can't
find how to erase a bunch of files in one go.

Specifically, I need a command that will erase *.zip files,
regardless of the text case of the .zip part....

So far, I have
   ls | grep -iE \\.zip$

That gives me the correct list of files.... but I don't know how to
get rm to process that list.. It doesn't look like rm has an option
to read the file name from stdin, it's expecting the file name as a
CLI argument.

This is one of those things that you could do a whole lot of ways and
I'm sure more than a few people will provide options.  I'm looking
forward to learning a few new things out of this too (it always
happens, no matter how well I think I know the possibilities :).

Here are a few ways:

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

You could use find instead of ls and grep too.  This example is
almost straight from the xargs man page:

    find -iname '*.zip' | xargs rm -f

Or, using some bash command substitution:

    rm -f $(ls | grep -iE \\.zip$)


WTF????????

Is everyone on drugs, here?

Or did:

rm -f *.zip

suddenly stop working, for some stupid reason?

Attachment: pgpfNRKeV5FD1.pgp
Description: PGP signature

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