1

I have files under nested directories like /x/0/0/0/a.txt till /x/9/9/9/a.txt To be more specific Under /x/ there are 0-9 folders Under /x/0/ there are 0-9 folders Under /x/0/0/ there are 0-9 folders Under/x/0/0/0/ there are files like a b c.

Now all these files needed to be copied to a directory like /y/ , where the previous directory structure should be followed.

arijit rakshit
  • 127
  • 1
  • 1
  • 6
  • What have you tried ? What is not working ? what does similar mean in this context ? identical or transformed in some way. All the files or just some of them ? – Sorin Feb 11 '20 at 08:12
  • [man 1 cp](http://man7.org/linux/man-pages/man1/cp.1.html)?? The `-a` option? – David C. Rankin Feb 11 '20 at 08:17
  • Does this answer your question? [How to copy in bash all directory and files recursive?](https://stackoverflow.com/questions/8055501/how-to-copy-in-bash-all-directory-and-files-recursive) – Maxim Sagaydachny Feb 11 '20 at 08:21
  • What is the final file name in /y/? – Wiimm Feb 11 '20 at 08:55

1 Answers1

0

Basically simplest "cp -r" is doing this task;

If you need to copy directory including "x"

cp -r /x /y/

Otherwise if you need only folders inside of "x"

cp -rp /x/* /y/
Bulikeri
  • 136
  • 7