Saturday, August 14, 2010

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.