I used this one to copy file in every dir:
find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess
Now i need to do reverse one and delete file with matching name from every sub directory of one i am currently in
If I understand your description correctly, you want to remove .htaccess from subdirectories of the current directory, but not from their subdirectories. In other words, you want to remove foo/.htaccess but not foo/bar/.htaccess. Then it's simple:
rm */.htaccess
You could have done without find for your initial command. find is mostly useful when you want to traverse a directory recursively, i.e. apply to the subdirectories and subsubdirectories and so on.
for d in */; do cp -p .htaccess "$d"; done
*/ is new for me, thanks! BTW I am quite sure the author just want to roll back the initial find. Maybe we should ask?
find /path/to/dir -name .htaccess -delete
find . …
-maxdepth 1 in the question, there's no implied recursivity).
The following assumes you previously run the find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess from the same directory you will run this one:
find . -maxdepth 2 -type f -name .htaccess -exec rm -v {} \;
The -v (verbose) option is optional but it helps to see what files are actually deleted.