Copy files by skipping parent directory
by Dman58 from LinuxQuestions.org on (#525M3)
Hi I'm trying to copy a large list of files from a directory. The directory format is as follows.
Code:Folder-
Parent-
Subfolder-
files to copy
Parent-
Subfolder-
files to copy
Parent-
Subfolder-
files to copyWhat I want is the subfolder and its contents skipping over the parent directory. I believe I need to use either some Regex or some kind of find command solution. I have tried the following with all kinds of various output.
This seems to be a good starting point, it shows the directories I want to begin with but when I try to pipe it into copy it seems to not like the syntax
Code:find /tmp/box1 -maxdepth 2This semi worked but files were copied into wrong locations:
Code:find /tmp/box1 -maxdepth 2 | xargs cp -R /tmp/box2Not working
Code:find /tmp/box1 -maxdepth 2 -type f -print0 | xargs cp -R /tmp/box2


Code:Folder-
Parent-
Subfolder-
files to copy
Parent-
Subfolder-
files to copy
Parent-
Subfolder-
files to copyWhat I want is the subfolder and its contents skipping over the parent directory. I believe I need to use either some Regex or some kind of find command solution. I have tried the following with all kinds of various output.
This seems to be a good starting point, it shows the directories I want to begin with but when I try to pipe it into copy it seems to not like the syntax
Code:find /tmp/box1 -maxdepth 2This semi worked but files were copied into wrong locations:
Code:find /tmp/box1 -maxdepth 2 | xargs cp -R /tmp/box2Not working
Code:find /tmp/box1 -maxdepth 2 -type f -print0 | xargs cp -R /tmp/box2