I have a template directory containing sub-directories and MS-Windows links. This directory needs to be sequentially reproduced at the same folder level. The range needs to be from one to twenty.

So, how do you do that from the command line?

  • 3
    Does not sound too hard, what did you try? What went wrong? Can you use symbolic links? – Tigger Jun 15 '17 at 8:19
  • 2
    This sounds like the usual "do my homework I am lazy" kind of question – Bruno9779 Jun 15 '17 at 8:37
  • "do my homework" ???? I spent a day trying to figure this out!!!! You Bruno - try to Google that and give a correct answer -as if I hadn't tried that! Keep your comments about laziness to yourself! – Gustav Jun 15 '17 at 11:42

After scouring the net I fell across some bits and pieces that did some of the things I was looking for, however they needed to be put together in a another way to run correctly from the command-line:

for ((start=4, count=2; $((count--)); $((start++)) ))
  cp -ar  "$base" "$base$start"

This does exactly what I need, and if you wish to use it as a script it'll work as well, but you your have to always edit the base=***** script to what ever your original directory is called, and edit the start=# variable to the number of copies you need.

I hope this will be a help to anyone looking for a way to make sequential copies of a directory.

| improve this answer | |

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.