Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.