Linux : Copy only directory structure without copying content

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.

Share this

Related Posts

Previous
Next Post »

5 comments

Write comments
Anonymous
August 10, 2010 at 7:12 PM delete

It's a smart way. Thanks.

Reply
avatar
Anonymous
December 18, 2012 at 2:18 PM delete

It does copy contents of the directories.

Reply
avatar
Anonymous
May 9, 2015 at 1:46 AM delete

does not --preserve associated information

Reply
avatar

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