HELP!! shell script for file removal...

HELP!! shell script for file removal...

Post by rav » Wed, 06 Oct 1993 00:20:24



hi,
   I want to write a shell script that will remove all copies of a
 file starting from one directory down to its subdirectories.

  Any hints , suggestions ???

ravi.

 
 
 

HELP!! shell script for file removal...

Post by Duane T. M » Wed, 06 Oct 1993 06:37:45



ravi> hi, I want to write a shell script that will remove all copies
ravi> of a file starting from one directory down to its
ravi> subdirectories.

Use find(1):

        find . -type f -name junkfile -exec rm -f {} \;

-- dtm

 
 
 

HELP!! shell script for file removal...

Post by Dan P » Wed, 06 Oct 1993 20:35:25



Quote:>hi,
>   I want to write a shell script that will remove all copies of a
> file starting from one directory down to its subdirectories.

>  Any hints , suggestions ???

Read the man page for find(1).
Your script will contain only one line :-)

Dan
--
Dan Pop
CERN, L3 Experiment

Mail:  CERN - PPE, Bat. 21 1-023, CH-1211 Geneve 23, Switzerland

 
 
 

HELP!! shell script for file removal...

Post by Francois-Michel La » Thu, 07 Oct 1993 05:38:23




>ravi> hi, I want to write a shell script that will remove all copies
>ravi> of a file starting from one directory down to its
>ravi> subdirectories.

>Use find(1):

>    find . -type f -name junkfile -exec rm -f {} \;

A better approach (which I just got flamed for *not* suggesting
over on comp.unix.misc) is to use the find ... -print | xargs
technique.  All this is assuming that the copies to be deleted
have the same name as the original file, of course.

---
------------------------------------------------------------------
Francois-Michel Lang          (202) 752-6067   FAX: (202) 752-4530


 
 
 

HELP!! shell script for file removal...

Post by Dhaliwal Bikram Sin » Sat, 09 Oct 1993 15:18:58



>hi,
>   I want to write a shell script that will remove all copies of a
> file starting from one directory down to its subdirectories.

>  Any hints , suggestions ???

>ravi.

sure try this:
find ./ -name $1 -exec rm $1 {} \;

(I think, this is what I use to rm core dumps in directories)
You don't even have to put it in a shell script, just alias it.

--
------------------------

Bikram Dhaliwal
(416) 845-4567