Problem in copying directory structure
Hi everyone.
I use (cd /old/directory; find -type d ! -name .) | xargs mkdir for copying directory structure into another location. It works. Then I found a problem. If I have folder named "linux newbie", or another folder that use space character. It will be splitted into 2 folder, "linux" and "newbie". Does anyone know how to repair my command? Please help me to modify my command. Thanks |
Hi and welcome!
Why don't you just rename your folder to linux_newbie,then your command will work. |
thanks for your advisement :)
but i need to copying directory structure, without renaming any directory. is there another way? :confused: |
cd $OLD_DIR && find . -type d ! -name . -exec mkdir $NEW_DIR/{} \;
|
To manage spaces inside file or directory names, you have to use the -print0 action of find and the corresponding -0 option of xargs. The former prints the path names terminated by a null character, the latter interprets arguments separated by a null character instead of the common field separators as blank space, tab and newline. You should end up with something like:
Code:
find . -type d ! -name . -print0 | xargs -0 mkdir Code:
rsync -av --include '*/' --exclude '*' /old/directory/* /new/directory |
Quote:
can is it possible to only copy the tree structure of the directory not the file content inside the directory to other directory.(Only tree structure of the directory). |
Quote:
|
Quote:
|
Quote:
|
thanks everybody :)
|
All times are GMT -5. The time now is 11:28 AM. |