Join Date: May Hi all Is it possible to copy a structure of a directory only. Regards J. Join Date: Feb Your post is similiar to this Use tar vino. Code :. MY apologies, but what I forgot to mention is that I dont want all the files in the tree. Hi Vino Thanks for the responses. What if I have my source listed in a file and want to use the for loop to do the copy. As mentioned, the copy works, but unfortunately does not copy the structure and only the file in the target dir.
Thanks J. Shell Programming and Scripting. Copying files from various folders to similar folder structure in another location. Hi, I need to write a script the has to copy the files from folders and subfolders to the same folder structure located in another location. Ex: mainfolder1 file1,file2,file3 subfolder1 file1,etc subfolder2 file1,etc to another folder location of same folder structure. Learn more. Asked 2 months ago. Active 2 months ago. Viewed 66 times.
Improve this question. Pleas explain why -r does not fulfill your requirements? What did you try? Add a comment. Improve this question. Rui F Ribeiro WG- WG- 1 1 silver badge 4 4 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Romeo Ninov Romeo Ninov Gander Gander 4 4 bronze badges. Please explain what is the change in behavior of the cp command in this case? Rich I also needed such a solution copying the whole path , and this switch helped me.
To copy more than one file at a time you can pass multiple input sources and a directory as destination:. Here the two input sources first. To copy a directory, you need to add the -r or -R flag—which is shorthand for --recursive :.
Here directory-1 containing the file a. To be prompted when an overwrite is about to occur, you can add the -i or --interactive flag:. Or, to prevent overwrites without being prompted, you can add the -n or --no-clobber flag:. There are many other useful options to pass to the cp command: like -v for "verbose" output or -f for "force.
0コメント