GNU bug report logs - #8079
rm command problem/suggestion

Previous Next

Package: coreutils;

Reported by: Luca Daniel <lucadaniel84 <at> gmail.com>

Date: Sat, 19 Feb 2011 01:36:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8079 in the body.
You can then email your comments to 8079 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8079; Package coreutils. (Sat, 19 Feb 2011 01:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Luca Daniel <lucadaniel84 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 19 Feb 2011 01:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Luca Daniel <lucadaniel84 <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: rm command problem/suggestion
Date: Sat, 19 Feb 2011 03:20:24 +0200
[Message part 1 (text/plain, inline)]
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   .
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 .
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) and this
is the problem ... it should be simple . So please give this a thought :) .
I am an exclusive GNU/Linux user and all I miss from windoze is the
simplicity of a simple command or switch .
I found this e-mail in the man pages so I hope a don't bother anyone with my
message as for this is not a bug, only a feature that I wish to see
implemented sometime in the future.
If there is a way to do it with only "rm" or a simple command and I missed
it please reply , I would be grateful .

Thank you.

Luca Daniel.
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8079; Package coreutils. (Sat, 19 Feb 2011 03:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 8079 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Luca Daniel <lucadaniel84 <at> gmail.com>
Cc: 8079 <at> debbugs.gnu.org
Subject: Re: bug#8079: rm command problem/suggestion
Date: Fri, 18 Feb 2011 20:08:41 -0700
[Message part 1 (text/plain, inline)]
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   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8079; Package coreutils. (Sat, 19 Feb 2011 03:12:02 GMT) Full text and rfc822 format available.

Message #11 received at 8079 <at> debbugs.gnu.org (full text, mbox):

From: "Alan Curry" <pacman-cu <at> kosh.dhis.org>
To: lucadaniel84 <at> gmail.com (Luca Daniel)
Cc: 8079 <at> debbugs.gnu.org
Subject: Re: bug#8079: rm command problem/suggestion
Date: Fri, 18 Feb 2011 22:10:59 -0500 (GMT+5)
Luca Daniel writes:
> 
> 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   .

You misplace the blame on rm; the problem is that the standard unix shell
doesn't have recursive globbing. Doing it in the shell means that all
utilities benefit. rm is just one of them.

zsh does recursive globbing with a double-asterisk, so that for example

  rm **/*.pdf

would get rid of all files named *.pdf anywhere under the current directory.
bash also knows about the ** recursive glob, but I recommend zsh because it
has a lot more cool features, like

  **/*.(pdf|ps)(m+30Lk-500)

(recursive directory search, all files named *.pdf or *.ps, whose last
modification was more than 30 days ago, with a size less than 500k)

-- 
Alan Curry




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8079; Package coreutils. (Sat, 19 Feb 2011 03:19:01 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: bug-coreutils <at> gnu.org
Cc: Luca Daniel <lucadaniel84 <at> gmail.com>, 8079 <at> debbugs.gnu.org
Subject: Re: bug#8079: rm command problem/suggestion
Date: Fri, 18 Feb 2011 22:18:30 -0500
[Message part 1 (text/plain, inline)]
On Friday, February 18, 2011 20:20:24 Luca Daniel wrote:
> 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   .
> 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 . 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) and this is the problem ... it should be simple . So please give
> this a thought :) . I am an exclusive GNU/Linux user and all I miss from
> windoze is the simplicity of a simple command or switch .
> I found this e-mail in the man pages so I hope a don't bother anyone with
> my message as for this is not a bug, only a feature that I wish to see
> implemented sometime in the future.
> If there is a way to do it with only "rm" or a simple command and I missed
> it please reply , I would be grateful .

sorry, but this is out of scope for `rm`.  what you want to do is trivial 
already though:
	find -name '*.pdf' -delete
-mike
[signature.asc (application/pgp-signature, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8079; Package coreutils. (Sat, 19 Feb 2011 03:19:02 GMT) Full text and rfc822 format available.

Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sat, 19 Feb 2011 10:53:01 GMT) Full text and rfc822 format available.

Notification sent to Luca Daniel <lucadaniel84 <at> gmail.com>:
bug acknowledged by developer. (Sat, 19 Feb 2011 10:53:02 GMT) Full text and rfc822 format available.

Message #22 received at 8079-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: 8079-done <at> debbugs.gnu.org
Subject: Re: bug#8079: rm command problem/suggestion
Date: Sat, 19 Feb 2011 11:52:10 +0100
Thanks to all who replied.
I'm closing this ticket.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 19 Mar 2011 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.