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 ? Commented Jul 3, 2015 at 18:14
  • @Serg The first one.
    – Sebi
    Commented 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" Commented Jul 3, 2015 at 18:19
  • 1
    @drewbenn post it as an answer Commented Jul 3, 2015 at 18:19
  • @serg, Did you test your code. I can not see how it can work. Commented 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .