Friday, November 2, 2007

How to copy directory

How to copy directory structure (without copying files)

cd [source]

find [source] -type d -print | sed s/[source]/[destination]/ | xargs mkdir

Substitute [source] and [destination] with the appropriate values, of course.

Explanation:

"-type d" finds all the directories

"-print" prints the directories

"-sed s/[source]/[destination]" substitutes source path with destination path

"xargs" runs a command on each word of input (be careful if your filename contains spaces)

No comments: