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

 
 

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

Submitted by:  Ville Hellman <bielet>
Submitted on:  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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

 

Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

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