Edit:
this is a resurrected necro-thread.
@vineel567, please indicate when you are re-opening an old thread so that readers don't confuse it with something being currently discussed. And don't re-open them at all unless you have something important to add to that discussion, such as a correction or updated info.
Your current post is fine in that regard, but I would recommend not trying to include hard-coded quotemarks in a command. Instead, use
null separators in
find and
xargs.
I'd also recommend using the
-p option in
mkdir to avoid error messages, and perhaps find's
-depth option (although that's not really necessary).
Finally, you shouldn't assume that find will operate on the PWD. Always explicitly give the directories it should start searching from.
Code:
cd /new/dir
( cd /old/dir ; find . -depth -type d ! -name . -print0 ) | xargs -0 mkdir -p
Another addition of my own, by the way:
How can I recreate a directory hierarchy structure, without the files?
http://mywiki.wooledge.org/BashFAQ/010
And please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.