bugfindutils - Bugs: bug #10461, -exec rm -rf {} \\; prints an...

 
 

bug #10461: -exec rm -rf {} \\; prints an error message

Submitter:  Ville Hellman <bielet>
Submitted:  Tue 21 Sep 2004 10:34:00 AM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  None Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 02 Oct 2004 10:24:21 AM UTC, comment #4: 

An alternative fix is to use the -depth option, which ensures that parent directories will be deleted only after child directories are deleted.

James Youngman <jay>
Group administrator
Wed 22 Sep 2004 07:21:06 AM UTC, comment #3: 

By the way, the non-GNU version of find (on HP-UX) succeeds also with the original usage of find:

find . -name directory_name -exec rm -rf {} \;

No errors printed and the directory is deleted.

Ville Hellman <bielet>
Wed 22 Sep 2004 07:05:59 AM UTC, comment #2: 


> Change your invocation of find to be the following.
> Remove the -r option from rm.
>
> find . -name directory_name -exec rm -f {} \;


If i do this, directory is not deleted. In order to delete directories, the -r option is required.

> Or better yet use find and xargs together.
> This is a more efficient method.
>
> find . -name somefile -print0 | xargs -r0 rm -f


This also does not resolve the problem: directory is still not deleted. Adding -r to command rm how ever does the trick.

Ville Hellman <bielet>
Tue 21 Sep 2004 04:01:47 PM UTC, comment #1: 

This is not a bug in find but a problem with your usage of it.  You are using 'rm -rf {}' and the -r recurses.  This removes files and directories at the same time that find is traversing them.

Change your invocation of find to be the following.  Remove the -r option from rm.

  find . -name directory_name -exec rm -f {} \;

Or better yet use find and xargs together.  This is a more efficient method.

  find . -name somefile -print0 | xargs -r0 rm -f

Bob Proulx <rwp>
Group Member
Tue 21 Sep 2004 10:34:00 AM UTC, original submission:  

Command find . -name directory_name -exec rm -rf {} \; prints an error message:

find: ./directory_name: No such file or directory

The directory is deleted how ever.

Ville Hellman <bielet>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-10-02 jay StatusNone Invalid
    Summary-exec rm -rf {} \; prints an error message -exec rm -rf {} \\; prints an error message
2004-09-21 rwp Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-4448.
Corresponding source code