Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a three folders: core, project and merge with many files inside. I want to delete all files and folders (including dot files) inside the merge folder, and then copy all files (including dot files) from the core folder to the merge folder, as well as merge all files in the project folder into the merge files.


  1. How can i remove all files and folders (including dot files) from special folders, without removing them? (rm -rf /path/to/folder/* did not delete files and folders.)
  2. What is fastest way to copy (with and without merge and replace) all files recursively from special folder to another one (including dot files)? (tar -cf my.tar path/; tar -xf my.tar)

I'm using tar but there are too many files and I need a faster way.

share|improve this question
Your description is a bit confusing, can you provide some example filenames and what you want the end result to be? – mgorven May 18 '12 at 5:12
@mgorven situation 1: rm -rf /path/to/folder/* did not remove dot files. – sweb May 18 '12 at 5:13
up vote 4 down vote accepted


rm -r merge/* merge/.*
rm: "." and ".." may not be removed

You can safely ignore that warning. Personally, I'd probably just rm -r merge and nuke the directory itself.


cp -r core/ merge/

... but that will overwrite the merge directory.

cd core && find . -exec cp "{}" "../merge/{}" \;

A bit slower and harder to write, but functional and doesn't clobber the parent directory.

All at once

rsync -av --delete core/ merge/
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.