I wanted to copy, entire folder structure, with files(may be using xcopy). The criteria is that the folder structure should have a particular folder name. For example , I want to copy the entire folder structure, where folder name has "ABC"(all the folder structure should be copied, whereever "ABC" folder name is present - rest should not be). If it is not possible in xcopy, is there anything in UNix?
1 Answer
Assuming I understood you correctly:
find directory/ -type d -name "ABC" && cp -r directory/ destination/
This will recursively copy directory
to destination
as long as directory
contains a sub-directory called ABC
.
-
Not sure, why. I get a "bash: [: too many arguments" error. Could it be because of the version?– SureshCommented Jul 22, 2013 at 16:51
-
There shouldn't have been any brackets. I'm not sure why I added those. I edited my answer.– user235731Commented Jul 22, 2013 at 17:24
-
This will actually copy everything recursively from directory to destination, whenever "ABC" is present. The source contains a lot of unwanted directories, I dont want to copy all the branches. I want to copy the braches, wherever "ABC" folder is present from source to destination. Sorry if my question was not clear.– SureshCommented Jul 23, 2013 at 10:54