Linux : Copy only directory structure without copying content

By Parthiban Ponnusamy

Some times, In Linux and UNIX, you may want to copy only the directory structure without copying the content and you want to create a similar directory structure in some other place. here is the quick way to do that.

Create the parent directory at wherever you want.

mkdir /where/ever/you/want

Example: mkdir /app01/data

switch to the directory from where you want to copy the directory structure.

cd /from/where/you/want/to/copy/directory/structure

Example: cd /app02/data

Now type the following command in the server terminal

find * -type d -exec mkdir /where/you/want/\{\} \;

Example: find * -type d -exec mkdir /app01/data/\{\} \;

Now the directory structure create in the new path where you specified as it is in the source.

For Further Reading,
Linux, Tips

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

{ 5 comments... read them below or add one }

Anonymous said...

It's a smart way. Thanks.

Parthiban Ponnusamy said...

Thanks for comment :)

Anonymous said...

Nice one

Anonymous said...

It does copy contents of the directories.

Anonymous said...

does not --preserve associated information

Post a Comment

What do you think about this Article? Add your Opinion..!