Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i found this online it copy file to every sub folder on the current dir for full tree depth

find -maxdepth 1 -type d -print0 | xargs -0 -n1 cp -v  .htaccess

now would be nice if it could ask if the file already exist or at least overwrite if file already exists.

Is there way to reverse this command so it can actually remove matching file from every subfolder?

share|improve this question
For confirmation of overwrite, add -i to the cp flags. – DerfK Nov 5 '11 at 9:56

Find is extremely versatile, the -delete and -name pattern options may helpful for what you want.

find -maxdepth 1 -type f -name '.htaccess' -delete
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.