bug-coreutils
[Top][All Lists]
Advanced

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

bug#8079: rm command problem/suggestion


From: Eric Blake
Subject: bug#8079: rm command problem/suggestion
Date: Fri, 18 Feb 2011 20:08:41 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 02/18/2011 06:20 PM, Luca Daniel wrote:
> Hi there :-)
> I have o problem and an suggestion :
> 1) The problem: I can't find an easy way to remove a type of file through
> all sub-directories with GNU tool "rm" (remove). There is not an option to
> search through all sub-folders , only in the current working directory. Back
> when I used windows this was easy with the command : del /s *.pdf   .

# Portable:
find . -name '*.pdf' -exec rm {} +

# Faster, if you use GNU findutils:
find -name '*.pdf' -delete

# Or, if you use bash:
# one-time setup - add this in your ~/.bashrc
shopt -s globstar
# then use ** for your goal
rm *.pdf **/*.pdf

> 2) The suggestion : please make an option for the "rm" command to look in
> sub-directories so it can be easier to use and increase functionality .

Sorry, but this would add bloat to rm, when the find utility already
exists for this purpose.  And even if we added it to GNU rm, it wouldn't
help you on any other Unix-like system where such a new option is not
present.  The philosophy of doing one thing well, and using the right
tool for the job, is rather important.

> I asked some people about this problem I have and the answer I got was not
> pretty in the sense that it was not a pretty command  =)  . I can't remember
> what is was because it was complicated (mixed with locate or find)

find may look daunting, but learning it will pay big dividends, as it is
then a very powerful tool in your toolbox.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]