It is currently Tue, 07 Dec 2021 03:17:51 GMT



 
Author Message
 find rm {} vs. rm -r
Right now I have my logout script set up to do, say:

        find ~/ -name *~ -exec rm -f {} \ ;

to get rid of those pesky emacs backup files.  This is, however, very
slow.  Would there be anything wrong with using instead:

        cd ~/
        rm -rf *~

I expect this should do the trick, but I am a little wary about
throwing around rm -rf commands in my directories. :)

Any comments by post or mail appreciated.

                                CJW

**********************************************************************
    /\       Colin J. Wynne             Washington and Lee University
   (())                                   E-Mail:  cwy...@wlu.edu
  /____\    Lunatic-at-Large           NeXT-Mail:  cwy...@sage.wlu.edu
 /______\  
/________\  



 Thu, 28 Mar 1996 05:37:42 GMT   
 find rm {} vs. rm -r
In article <1993Oct9.213742.28...@liberty.uc.wlu.edu>,
Colin J. Wynne <cwy...@liberty.uc.wlu.edu> wrote:

No, won't work as you expect it to.

1) It won't find '~' files in any subdirectories ...

2) If you have any subdirectory called ~/whatever~ it will be totally
erased.

Personally, I suggest this:

   find ~ -name \*~ -atime +3 -print | xargs rm

And it will keep the files around for three days before deleting
them.  They tend to be useful, I think ...

( the '-print | xargs rm' is just another way of doing it.  xargs is
the tool of the gods! )

I set up my logout script to do this sort of thing, but to move the
files into a ~/.trash directory, then delete them 3 days later ...

It also did it in the background, so I got logged out right away ...

--
Doug McLaren, dou...@utpapa.ph.utexas.edu, dou...@ccwf.cc.utexas.edu,



 Thu, 28 Mar 1996 14:38:45 GMT   
 find rm {} vs. rm -r

(BTW- "xargs" is often used by OlympusNet, if my sources are correct..)

The MAIN disadvantage to "rm -r *" is the fact that the shell has to do
the expansion for you.  On small filesystems, you may not notice it, but
if you're writing scripts that might be used on multi-Gig systems, you
could very well run up against a "string too long" error.

"find" with "xargs" is usually the safest way to go.

John
--
John Wiegley              (703) 430-9247                 jo...@vti.com
AIB Software, Inc.        46030 Manekin Plaza            Dulles, VA 20166
Formerly
   Virtual Technologies, Inc.



 Fri, 29 Mar 1996 11:03:02 GMT   
 find rm {} vs. rm -r
Two people have mentioned xargs in responding to my original post.
What is it???  

CJW

**********************************************************************
    /\       Colin J. Wynne             Washington and Lee University
   (())                                   E-Mail:  cwy...@wlu.edu
  /____\    Lunatic-at-Large           NeXT-Mail:  cwy...@sage.wlu.edu
 /______\  
/________\  



 Sat, 30 Mar 1996 00:56:08 GMT   
 find rm {} vs. rm -r
Of course I should use it as a background process (duh <slap forehead>).

Does ksh kill bg processes on logout, meaning I should run the logout
script nohup?

CJW

**********************************************************************
    /\       Colin J. Wynne             Washington and Lee University
   (())                                   E-Mail:  cwy...@wlu.edu
  /____\    Lunatic-at-Large           NeXT-Mail:  cwy...@sage.wlu.edu
 /______\  
/________\  



 Sat, 30 Mar 1996 01:05:21 GMT   
 find rm {} vs. rm -r
Hi All-

IMHO, xargs is really cool-

You can take the output from a simple find command and use the output as
args for any command:

find . -name "*.old" -print | xargs rm -f

whereas find . -name "*.old" exec ( or whatever comes next ) aint so cool.

poohb...@ejv.com



 Tue, 02 Apr 1996 09:35:25 GMT   
 
   [ 6 post ] 

Similar Threads

1. rm command needs rm -r on RedHat

2. (sol8 (intel))alias rm to rm -i in ksh88

3. rm won't rm

4. rm files found by find command in script

5. find -exec find -exec rm

6. corrupted e2fs filesystem -- can't rm lost+found/*

7. lost+found cant rm

8. find /tmp -atime +1 | rm does not dele

9. find /tmp -atime +1 | rm does not dele

10. find /tmp -atime +1 | rm does not delete my old tmp files :-(


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software