-1

We have a bunch of old deprecated files that reside inside of 400 subdomain directories.

I'm trying to delete them out in 1 shot.

One of these old pages is called index1.php. I was able to figure out the following in SSH to give me a list of all these files.

I did get a list, but not a count, which would be very helpful.

 find . -name index1.php

How do I go from this to make the server delete all these files it found with the name 'index1.php'

Thanks!!

Kevin
  • 125
  • 2
  • 4

1 Answers1

2

Take a look at the list of potential files you could delete...

find . -name "index1.php" - Are you absolutely sure you want to remove them?

If so, something like:

find . -name "index1.php" -delete

or

find . -name "index1.php" -exec rm -f {} \;

ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • Thank you. Yes, I'm sure I want to remove these particular file. What is the difference between the -delete option and the -exec rm option? Do they offer different things? Also, is it possible to get a count at the end to see how many were deleted? – Kevin Feb 11 '13 at 21:03
  • Speed, efficiency... it's one thing if you have 400 files to delete... but if there are 40,000 files, a different approach could be taken. For file counts, maybe something like `find . -name "index1.php" | wc -l` – ewwhite Feb 11 '13 at 21:04
  • If you are deleting 40,000 files (or more), I recommend 'find . -name index1.php -print0 | xargs -0 rm -f' as being more efficient than -exec rm for large numbers of files. – Slartibartfast Feb 12 '13 at 06:34