0

How can I copy a number of directories:

directory_01
directory_02
directory_03

to different directories

tmp_directory_01
tmp_directory_02
tmp_directory_03

where each tmp_directory_* directory has the same content(files and subdirectories) as directory_*. For example tmp_directory_01 will have the same contents as directory_01.

6
  • You want to copy only the contents of directory_x to tmp_directory_x or you want to have directory_x as subdirectory of tmp_directory_x ? Jul 3, 2015 at 18:14
  • @Serg The first one.
    – Sebi
    Jul 3, 2015 at 18:15
  • @Sebi then you may want to go with drewbenn's method , except I'd change the code to cp -R "$d"/* "tmp_$d" Jul 3, 2015 at 18:19
  • 1
    @drewbenn post it as an answer Jul 3, 2015 at 18:19
  • @serg, Did you test your code. I can not see how it can work. Jul 3, 2015 at 18:23

1 Answer 1

1

Posting comment as answer:

for d in directory_*; do cp -R "$d" "tmp_$d"; done

Credits @drewbenn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.