[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: deleting specific files



Hi Karsten,

thank you very much for your very detailed answer! 

Abrazos,

Marcelo

On Mon, Mar 26, 2001 at 03:09:35PM -0800, Karsten M. Self wrote:
> Please respond to list mail on-list.  Reply redirected to list.  
> Reply-to: set to list.
> 
> on Mon, Mar 26, 2001 at 07:23:15PM -0300, Marcelo Chiapparini (chiappa@uerj.br) wrote:
> > Karsten
> > 
> > thank you very much for your illustrating answer!
> > Now, I am new to linux and Debian, so I would like to understand more 
> > of your answer:
> > 
> > > > > I need to delete a bunch of files, all of them of the form 
> > > > > *.doc, scattered into several subdirectories inside a given
> > > > > directory. What should I do?
> > <snip> 
> > > Several options:
> > >   - Create a script.  This *is* my preferred method.
> > > 
> > >      $ find . -type f -name \*.doc | sed -e '/.*/s//rm &/' > rmscript
> > >      # Edit the script to make sure it's got The Right Stuff
> > >      $ vi rmscript
> > >      # run it
> > >      $ chmod +x rmscript; ./rmscript
> > > 
> > 
> > where is the script in your example above? (sorry, I knew this is a
> > stupid question, but...). Of course the script's name is rmscript, but
> > what's inside it?
> 
> Well, the easy answer is "run it and see".
> 
> Initially, the output from the find command, with 'rm ' prepended to the
> start of each line.  After you edit it, whatever you've added or
> removed.
> 
> Say I've got a directory tree:
> 
>     /tmp/foo
>     `-- bar
> 	`-- baz
> 
> With the following files in it:
> 
>     /tmp/foo/bar/qux.doc
>     /tmp/foo/bar.doc
>     /tmp/foo/baz.doc
> 
> When I run the find command listed above, rmscript contains:
> 
>     rm /tmp/foo/bar/qux.doc
>     rm /tmp/foo/bar.doc
>     rm /tmp/foo/baz.doc
> 
> Supposing I wanted to keep 'qux.doc', I'd edit it out of the script
> (delete the line).
> 
> How exactly you deal with the file is up to you.  While I've
> programmatically created all the commands (in this simple instance), you
> could also just dump in a raw list of filenames and use vi editing
> commands to substitute and replace within the script.
> 
> > thank you for your patiente...
> 
> De nada.  (Sorry, I know that's Spanish and not Portuguese).
> 
> -- 
> Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
>  What part of "Gestalt" don't you understand?       There is no K5 cabal
>   http://gestalt-system.sourceforge.net/         http://www.kuro5hin.org



-- 
Marcelo Chiapparini
DFT-IF/UERJ
chiappa@uerj.br



Reply to: