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