Duplicate file x times in command shell

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












16















I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work:



for i in 1..100; do cp test.ogg echo "test$1.ogg"; done









share|improve this question



















  • 4





    Isn't your only error the echo which should not be there, and the $1 which should be $i?

    – Julie Pelletier
    Jun 21 '16 at 6:44












  • if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

    – Black
    Jun 21 '16 at 6:45











  • @EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

    – cuonglm
    Jun 21 '16 at 6:47











  • @JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

    – Black
    Jun 21 '16 at 6:49
















16















I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work:



for i in 1..100; do cp test.ogg echo "test$1.ogg"; done









share|improve this question



















  • 4





    Isn't your only error the echo which should not be there, and the $1 which should be $i?

    – Julie Pelletier
    Jun 21 '16 at 6:44












  • if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

    – Black
    Jun 21 '16 at 6:45











  • @EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

    – cuonglm
    Jun 21 '16 at 6:47











  • @JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

    – Black
    Jun 21 '16 at 6:49














16












16








16


7






I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work:



for i in 1..100; do cp test.ogg echo "test$1.ogg"; done









share|improve this question
















I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work:



for i in 1..100; do cp test.ogg echo "test$1.ogg"; done






shell files file-copy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 21 '16 at 9:44









Gilles

537k12810851603




537k12810851603










asked Jun 21 '16 at 6:34









BlackBlack

5212929




5212929







  • 4





    Isn't your only error the echo which should not be there, and the $1 which should be $i?

    – Julie Pelletier
    Jun 21 '16 at 6:44












  • if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

    – Black
    Jun 21 '16 at 6:45











  • @EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

    – cuonglm
    Jun 21 '16 at 6:47











  • @JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

    – Black
    Jun 21 '16 at 6:49













  • 4





    Isn't your only error the echo which should not be there, and the $1 which should be $i?

    – Julie Pelletier
    Jun 21 '16 at 6:44












  • if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

    – Black
    Jun 21 '16 at 6:45











  • @EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

    – cuonglm
    Jun 21 '16 at 6:47











  • @JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

    – Black
    Jun 21 '16 at 6:49








4




4





Isn't your only error the echo which should not be there, and the $1 which should be $i?

– Julie Pelletier
Jun 21 '16 at 6:44






Isn't your only error the echo which should not be there, and the $1 which should be $i?

– Julie Pelletier
Jun 21 '16 at 6:44














if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

– Black
Jun 21 '16 at 6:45





if i remove the echo and only use test$1.ogg then it says: test.ogg and test.ogg are the same files, so it seems like $1 is not recognized?

– Black
Jun 21 '16 at 6:45













@EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

– cuonglm
Jun 21 '16 at 6:47





@EdwardBlack: Sound like I mis-understood your requirements. That solution is not suitable.

– cuonglm
Jun 21 '16 at 6:47













@JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

– Black
Jun 21 '16 at 6:49






@JuliePelletier, damn, it happens sometimes to me that i accidentially write $1 instead of $i, it is earlie in the morning, sorry... thank you. I will use $x in the future instead of $i

– Black
Jun 21 '16 at 6:49











5 Answers
5






active

oldest

votes


















20














Your shell code has two issues:



  1. The echo should not be there.

  2. The variable $i is mistyped as $1 in the destination file name.

To make a copy of a file in the same directory as the file itself, use



cp thefile thecopy


If you insert anything else in there, e.g.



cp thefile theotherthing thecopy


then it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.



In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.



The $1 will most likely expand to an empty string. This is why, when you delete the echo from the command, you get "test.ogg and test.ogg are the same files"; the command being executed is essentially



cp test.ogg test.ogg


This is probably a mistyping.



In the end, you want something like this:



for i in 1..100; do cp test.ogg "test$i.ogg"; done


Or, as an alternative



i=0
while (( i++ < 100 )); do
cp test.ogg "test$i.ogg"
done


Or, using tee:



tee test1..100.ogg <test.ogg >/dev/null





share|improve this answer
































    11














    Short and precise



    < test.ogg tee test1..100.ogg


    or even better do



    tee test1..100.ogg < test.ogg >/dev/null


    see tee command usage for more help.



    Update



    as suggested by @Gilles, using tee has the defect of not preserving any file metadata. To overcome that issue, you might have to run below command after that:



    cp --attributes-only --preserve Source Target





    share|improve this answer




















    • 3





      This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

      – Gilles
      Jun 21 '16 at 9:44











    • @Gilles ohh, can we overcome that ?

      – Rahul
      Jun 21 '16 at 10:09






    • 3





      You can run cp --attributes-only afterwards.

      – Gilles
      Jun 21 '16 at 11:50











    • @Gilles thanks, updated my answer as per your help.

      – Rahul
      Jun 21 '16 at 11:57











    • FWIW none of the other answers used cp -p to preserve metadata either.

      – roaima
      Jun 6 '17 at 20:03


















    9














    for i in 1..100; do cp test.ogg "test_$i.ogg" ; done





    share|improve this answer




















    • 1





      Variable expansions should be quoted.

      – cat
      Jun 21 '16 at 20:29


















    1














    The folowing command will copy file.a 5 times:



    $ seq 5 | xargs -I AA cp file.a fileAA.a


    If you prefer dd (not the same as cp!):



    $ seq 5 | xargs -I AA dd if=file.a of=fileAA.a





    share|improve this answer
































      0














      You have not called variable i while copying



      use below script . As tested it worked fine



      for i in 1..10; do cp -rvfp test.ogg test$i.ogg ;done





      share|improve this answer


















      • 2





        This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

        – Scott
        Jan 17 '18 at 20:03










      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f291065%2fduplicate-file-x-times-in-command-shell%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      20














      Your shell code has two issues:



      1. The echo should not be there.

      2. The variable $i is mistyped as $1 in the destination file name.

      To make a copy of a file in the same directory as the file itself, use



      cp thefile thecopy


      If you insert anything else in there, e.g.



      cp thefile theotherthing thecopy


      then it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.



      In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.



      The $1 will most likely expand to an empty string. This is why, when you delete the echo from the command, you get "test.ogg and test.ogg are the same files"; the command being executed is essentially



      cp test.ogg test.ogg


      This is probably a mistyping.



      In the end, you want something like this:



      for i in 1..100; do cp test.ogg "test$i.ogg"; done


      Or, as an alternative



      i=0
      while (( i++ < 100 )); do
      cp test.ogg "test$i.ogg"
      done


      Or, using tee:



      tee test1..100.ogg <test.ogg >/dev/null





      share|improve this answer





























        20














        Your shell code has two issues:



        1. The echo should not be there.

        2. The variable $i is mistyped as $1 in the destination file name.

        To make a copy of a file in the same directory as the file itself, use



        cp thefile thecopy


        If you insert anything else in there, e.g.



        cp thefile theotherthing thecopy


        then it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.



        In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.



        The $1 will most likely expand to an empty string. This is why, when you delete the echo from the command, you get "test.ogg and test.ogg are the same files"; the command being executed is essentially



        cp test.ogg test.ogg


        This is probably a mistyping.



        In the end, you want something like this:



        for i in 1..100; do cp test.ogg "test$i.ogg"; done


        Or, as an alternative



        i=0
        while (( i++ < 100 )); do
        cp test.ogg "test$i.ogg"
        done


        Or, using tee:



        tee test1..100.ogg <test.ogg >/dev/null





        share|improve this answer



























          20












          20








          20







          Your shell code has two issues:



          1. The echo should not be there.

          2. The variable $i is mistyped as $1 in the destination file name.

          To make a copy of a file in the same directory as the file itself, use



          cp thefile thecopy


          If you insert anything else in there, e.g.



          cp thefile theotherthing thecopy


          then it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.



          In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.



          The $1 will most likely expand to an empty string. This is why, when you delete the echo from the command, you get "test.ogg and test.ogg are the same files"; the command being executed is essentially



          cp test.ogg test.ogg


          This is probably a mistyping.



          In the end, you want something like this:



          for i in 1..100; do cp test.ogg "test$i.ogg"; done


          Or, as an alternative



          i=0
          while (( i++ < 100 )); do
          cp test.ogg "test$i.ogg"
          done


          Or, using tee:



          tee test1..100.ogg <test.ogg >/dev/null





          share|improve this answer















          Your shell code has two issues:



          1. The echo should not be there.

          2. The variable $i is mistyped as $1 in the destination file name.

          To make a copy of a file in the same directory as the file itself, use



          cp thefile thecopy


          If you insert anything else in there, e.g.



          cp thefile theotherthing thecopy


          then it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.



          In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.



          The $1 will most likely expand to an empty string. This is why, when you delete the echo from the command, you get "test.ogg and test.ogg are the same files"; the command being executed is essentially



          cp test.ogg test.ogg


          This is probably a mistyping.



          In the end, you want something like this:



          for i in 1..100; do cp test.ogg "test$i.ogg"; done


          Or, as an alternative



          i=0
          while (( i++ < 100 )); do
          cp test.ogg "test$i.ogg"
          done


          Or, using tee:



          tee test1..100.ogg <test.ogg >/dev/null






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 25 at 22:45

























          answered Jun 21 '16 at 7:02









          KusalanandaKusalananda

          129k17246404




          129k17246404























              11














              Short and precise



              < test.ogg tee test1..100.ogg


              or even better do



              tee test1..100.ogg < test.ogg >/dev/null


              see tee command usage for more help.



              Update



              as suggested by @Gilles, using tee has the defect of not preserving any file metadata. To overcome that issue, you might have to run below command after that:



              cp --attributes-only --preserve Source Target





              share|improve this answer




















              • 3





                This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

                – Gilles
                Jun 21 '16 at 9:44











              • @Gilles ohh, can we overcome that ?

                – Rahul
                Jun 21 '16 at 10:09






              • 3





                You can run cp --attributes-only afterwards.

                – Gilles
                Jun 21 '16 at 11:50











              • @Gilles thanks, updated my answer as per your help.

                – Rahul
                Jun 21 '16 at 11:57











              • FWIW none of the other answers used cp -p to preserve metadata either.

                – roaima
                Jun 6 '17 at 20:03















              11














              Short and precise



              < test.ogg tee test1..100.ogg


              or even better do



              tee test1..100.ogg < test.ogg >/dev/null


              see tee command usage for more help.



              Update



              as suggested by @Gilles, using tee has the defect of not preserving any file metadata. To overcome that issue, you might have to run below command after that:



              cp --attributes-only --preserve Source Target





              share|improve this answer




















              • 3





                This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

                – Gilles
                Jun 21 '16 at 9:44











              • @Gilles ohh, can we overcome that ?

                – Rahul
                Jun 21 '16 at 10:09






              • 3





                You can run cp --attributes-only afterwards.

                – Gilles
                Jun 21 '16 at 11:50











              • @Gilles thanks, updated my answer as per your help.

                – Rahul
                Jun 21 '16 at 11:57











              • FWIW none of the other answers used cp -p to preserve metadata either.

                – roaima
                Jun 6 '17 at 20:03













              11












              11








              11







              Short and precise



              < test.ogg tee test1..100.ogg


              or even better do



              tee test1..100.ogg < test.ogg >/dev/null


              see tee command usage for more help.



              Update



              as suggested by @Gilles, using tee has the defect of not preserving any file metadata. To overcome that issue, you might have to run below command after that:



              cp --attributes-only --preserve Source Target





              share|improve this answer















              Short and precise



              < test.ogg tee test1..100.ogg


              or even better do



              tee test1..100.ogg < test.ogg >/dev/null


              see tee command usage for more help.



              Update



              as suggested by @Gilles, using tee has the defect of not preserving any file metadata. To overcome that issue, you might have to run below command after that:



              cp --attributes-only --preserve Source Target






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 21 '16 at 11:57

























              answered Jun 21 '16 at 6:59









              RahulRahul

              9,23412843




              9,23412843







              • 3





                This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

                – Gilles
                Jun 21 '16 at 9:44











              • @Gilles ohh, can we overcome that ?

                – Rahul
                Jun 21 '16 at 10:09






              • 3





                You can run cp --attributes-only afterwards.

                – Gilles
                Jun 21 '16 at 11:50











              • @Gilles thanks, updated my answer as per your help.

                – Rahul
                Jun 21 '16 at 11:57











              • FWIW none of the other answers used cp -p to preserve metadata either.

                – roaima
                Jun 6 '17 at 20:03












              • 3





                This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

                – Gilles
                Jun 21 '16 at 9:44











              • @Gilles ohh, can we overcome that ?

                – Rahul
                Jun 21 '16 at 10:09






              • 3





                You can run cp --attributes-only afterwards.

                – Gilles
                Jun 21 '16 at 11:50











              • @Gilles thanks, updated my answer as per your help.

                – Rahul
                Jun 21 '16 at 11:57











              • FWIW none of the other answers used cp -p to preserve metadata either.

                – roaima
                Jun 6 '17 at 20:03







              3




              3





              This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

              – Gilles
              Jun 21 '16 at 9:44





              This is potentially faster than multiple calls to cp (depends on the file size relative to available memory), but has the defect of not preserving any file metadata.

              – Gilles
              Jun 21 '16 at 9:44













              @Gilles ohh, can we overcome that ?

              – Rahul
              Jun 21 '16 at 10:09





              @Gilles ohh, can we overcome that ?

              – Rahul
              Jun 21 '16 at 10:09




              3




              3





              You can run cp --attributes-only afterwards.

              – Gilles
              Jun 21 '16 at 11:50





              You can run cp --attributes-only afterwards.

              – Gilles
              Jun 21 '16 at 11:50













              @Gilles thanks, updated my answer as per your help.

              – Rahul
              Jun 21 '16 at 11:57





              @Gilles thanks, updated my answer as per your help.

              – Rahul
              Jun 21 '16 at 11:57













              FWIW none of the other answers used cp -p to preserve metadata either.

              – roaima
              Jun 6 '17 at 20:03





              FWIW none of the other answers used cp -p to preserve metadata either.

              – roaima
              Jun 6 '17 at 20:03











              9














              for i in 1..100; do cp test.ogg "test_$i.ogg" ; done





              share|improve this answer




















              • 1





                Variable expansions should be quoted.

                – cat
                Jun 21 '16 at 20:29















              9














              for i in 1..100; do cp test.ogg "test_$i.ogg" ; done





              share|improve this answer




















              • 1





                Variable expansions should be quoted.

                – cat
                Jun 21 '16 at 20:29













              9












              9








              9







              for i in 1..100; do cp test.ogg "test_$i.ogg" ; done





              share|improve this answer















              for i in 1..100; do cp test.ogg "test_$i.ogg" ; done






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 21 '16 at 20:32

























              answered Jun 21 '16 at 6:45









              coffeMugcoffeMug

              7,268112848




              7,268112848







              • 1





                Variable expansions should be quoted.

                – cat
                Jun 21 '16 at 20:29












              • 1





                Variable expansions should be quoted.

                – cat
                Jun 21 '16 at 20:29







              1




              1





              Variable expansions should be quoted.

              – cat
              Jun 21 '16 at 20:29





              Variable expansions should be quoted.

              – cat
              Jun 21 '16 at 20:29











              1














              The folowing command will copy file.a 5 times:



              $ seq 5 | xargs -I AA cp file.a fileAA.a


              If you prefer dd (not the same as cp!):



              $ seq 5 | xargs -I AA dd if=file.a of=fileAA.a





              share|improve this answer





























                1














                The folowing command will copy file.a 5 times:



                $ seq 5 | xargs -I AA cp file.a fileAA.a


                If you prefer dd (not the same as cp!):



                $ seq 5 | xargs -I AA dd if=file.a of=fileAA.a





                share|improve this answer



























                  1












                  1








                  1







                  The folowing command will copy file.a 5 times:



                  $ seq 5 | xargs -I AA cp file.a fileAA.a


                  If you prefer dd (not the same as cp!):



                  $ seq 5 | xargs -I AA dd if=file.a of=fileAA.a





                  share|improve this answer















                  The folowing command will copy file.a 5 times:



                  $ seq 5 | xargs -I AA cp file.a fileAA.a


                  If you prefer dd (not the same as cp!):



                  $ seq 5 | xargs -I AA dd if=file.a of=fileAA.a






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 5 '18 at 16:14

























                  answered Jan 15 '18 at 14:17









                  cy8g3ncy8g3n

                  216




                  216





















                      0














                      You have not called variable i while copying



                      use below script . As tested it worked fine



                      for i in 1..10; do cp -rvfp test.ogg test$i.ogg ;done





                      share|improve this answer


















                      • 2





                        This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                        – Scott
                        Jan 17 '18 at 20:03















                      0














                      You have not called variable i while copying



                      use below script . As tested it worked fine



                      for i in 1..10; do cp -rvfp test.ogg test$i.ogg ;done





                      share|improve this answer


















                      • 2





                        This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                        – Scott
                        Jan 17 '18 at 20:03













                      0












                      0








                      0







                      You have not called variable i while copying



                      use below script . As tested it worked fine



                      for i in 1..10; do cp -rvfp test.ogg test$i.ogg ;done





                      share|improve this answer













                      You have not called variable i while copying



                      use below script . As tested it worked fine



                      for i in 1..10; do cp -rvfp test.ogg test$i.ogg ;done






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 15 '18 at 14:32









                      Praveen Kumar BSPraveen Kumar BS

                      1,474138




                      1,474138







                      • 2





                        This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                        – Scott
                        Jan 17 '18 at 20:03












                      • 2





                        This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                        – Scott
                        Jan 17 '18 at 20:03







                      2




                      2





                      This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                      – Scott
                      Jan 17 '18 at 20:03





                      This is the same as two previous answers and a comment except (1) the question asks about 100, and your answer uses 10, (2) you have unnecessarily added the -rvf options to cp, and (3) you have failed to quote your variable expansion. (Also note that it’s conventional to have a space between punctuation symbols like ; and the following word.) The addition of the -p option is valuable, but (4a) it’s been addressed already (in comments), and (4b) your answer isn’t helpful if you don’t explain what you’re doing.

                      – Scott
                      Jan 17 '18 at 20:03

















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f291065%2fduplicate-file-x-times-in-command-shell%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay