Click to See Complete Forum and Search --> : delete a file recursively


eXtremist
10-24-2001, 02:36 PM
This may have been asked before, but I clicked SEARCH and waited about 15 minutes (went and made a coffee) and still nothing came up, so I'm asking it here.

I recently used wget to recursively-suck down the OLGA (online guitar archives), but the server I got it from placed an index.html file in EVERY directory.

How can I rid myself of these index files easily?

Icarus
10-24-2001, 02:51 PM
rm -R *.index

some versions of Linux you might need to add a -f or you'll be asked if you want to delete on every file.

I use HP-UX 11.0 at work and Red Hat 7.1 (7.2 once it finishes downloading) at home. I'll be corrected if this isn't the right way for you :)

eXtremist
10-24-2001, 03:07 PM
Hello and thanks for your reply...

First off, this command did not work for me.

I assumed you meant *.html instead of *.index .. but I tried both anyway. I even tried rm -R index.html.

This deletes the index.html file from the current directory, but it does nothing to the index.html's in the other directories.. :(

thanks for your help anyway

X_console
10-24-2001, 04:32 PM
This is what you want:

find ./ -name index.html -exec rm -f {} \;

Go to the top directory of this olga directory or whatever, and then run this. All index.html files in this directory and subdirectories will be deleted.

eXtremist
10-24-2001, 10:24 PM
wow.. what a useful little command.. thanks a lot..!! I'll be using this one in the future for sure.

Icarus
10-25-2001, 09:40 AM
Ah, I knew something was wrong with that...I didn't see that you had these in other directories, I feel uneasy about running a rm throughout the whole system...but that's just me :)

X_console
10-25-2001, 12:58 PM
If you replace -exec with -ok, it will ask for your confirmation before deleting the file.

eXtremist
10-25-2001, 02:56 PM
One question.. Can you tell me what the trailing \ does?

I tried issuing the command as follows:

find ./ -name index.html -exec 'rm -f {}'

and got an error. The man page says the command may need to be ended with a \ or encapsulated in quotes. Why don't the quotes work?

Strogian
10-25-2001, 03:36 PM
Perhaps they mean double quotes? " "