0

I was wondering if it's possible to copy multiple specific directories recursively at once.

I know I can copy all sub-directories like so

cp -rp root/pass/dir/* root/other/dir/

But I'm wondering if I can recursively copy specific directories like with files

cp -p root/pass/dir/subdir/file{1,2,3}.php root/other/dir/

Lets say, in dir there are sub-directories subdir1, subdir2, subdir3.

Can I copy them recursively in the same way? e.g.

cp -rp root/pass/dir/subdir{1,2}/ root/other/dir/
Y12K
  • 101
  • 3
  • 1
    Have you tried ? All three examples you provide are missing a destination, I think. – Soren A May 01 '17 at 09:30
  • No, company doesn't like me "trying" stuff on their servers. And I'll add a dest but not really about that... – Y12K May 01 '17 at 09:33
  • You can simply test this things on some empty directories; And something like cp -rp /path/dir/{1,2} /dest/paty works fine. – Ravexina May 01 '17 at 09:35
  • @Ravexina any documentation? I really haven't been able to find anything about it. – Y12K May 01 '17 at 09:40
  • http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html – Ravexina May 01 '17 at 09:42

1 Answers1

0

Yes it will work. If company don't like you testing in production, they of course provide a test-system ? Or you can test in a vm on ypur pc, for instance in VirtualBox.

Soren A
  • 6,799