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 want to copy about 200 directories & subdirectories from one location to another but I don't want to copy the thousands of files within those directories. I am on Linux.

Note: I don't have enough space to copy everything then delete all the files.

share|improve this question
up vote 10 down vote accepted

Just found this:

rsync -a -f"+ */" -f"- *" source/ destination/

share|improve this answer
find some/dir -type d -print0 | rsync --files-from=/dev/stdin -0 ...
share|improve this answer

You also can do :

find inputdir -type d | cpio -pdumv destdir

The power of simplicity ;)

share|improve this answer

Another approach is with find and mkdir:

find SOURCE -type d -exec mkdir TARGET/{} \;

Just make sure TARGET already exists or use the -p option of mkdir.

share|improve this answer

Similarly, using (GNU) tar:

find some/dir -type d -print |
tar --no-recursion -T- -c -p -f- |
(cd another/dir && tar -x -p -f-)

You don't really need the -print0 on the find command line or the -0 on the rsync command line unless you have filenames that contain newline characters (which is possible but highly unlikely). Tar (and rsync, and cpio) read filenames line-by-line; using a NULL terminator is mostly useful with xargs, which normally reads whitespace separated filenames (and so does not handle files/directories with spaces in their names without -0).

share|improve this answer
cp -al 

Would copy all files with hard links. Same structure, same permissions. (note: hard links, so no storage lost.)

share|improve this answer
It is not possible to create hard links across filesystem boundaries – MountainX Jun 9 at 1:32
True, but it wasn't said that it was across filesystem ... – Svenn Dhert Jun 9 at 11:48

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.