Copying & Renaming Files with GNU Parallel












0















I have a simple script that I want to copy and rename files, in files.lst based on a list of names in names.lst



**name.lst**
100GV200.vcf
150GV200.vcf
14300GV200.vcf

**file.lst**
file1.txt
file2.txt
file3.txt


My script so far looks like this:



parallel --link -k "cp {} {}" :::: file.lst :::: name.lst


Unfortunately I get back:



 cp: target `100GV200.vcf` is not a directory


When I run a single cp command in the terminal it works perfectly



cp file1.txt 100GV200.vcf


Where am I going wrong in understanding how GNU parallel reads in arguments?










share|improve this question



























    0















    I have a simple script that I want to copy and rename files, in files.lst based on a list of names in names.lst



    **name.lst**
    100GV200.vcf
    150GV200.vcf
    14300GV200.vcf

    **file.lst**
    file1.txt
    file2.txt
    file3.txt


    My script so far looks like this:



    parallel --link -k "cp {} {}" :::: file.lst :::: name.lst


    Unfortunately I get back:



     cp: target `100GV200.vcf` is not a directory


    When I run a single cp command in the terminal it works perfectly



    cp file1.txt 100GV200.vcf


    Where am I going wrong in understanding how GNU parallel reads in arguments?










    share|improve this question

























      0












      0








      0








      I have a simple script that I want to copy and rename files, in files.lst based on a list of names in names.lst



      **name.lst**
      100GV200.vcf
      150GV200.vcf
      14300GV200.vcf

      **file.lst**
      file1.txt
      file2.txt
      file3.txt


      My script so far looks like this:



      parallel --link -k "cp {} {}" :::: file.lst :::: name.lst


      Unfortunately I get back:



       cp: target `100GV200.vcf` is not a directory


      When I run a single cp command in the terminal it works perfectly



      cp file1.txt 100GV200.vcf


      Where am I going wrong in understanding how GNU parallel reads in arguments?










      share|improve this question














      I have a simple script that I want to copy and rename files, in files.lst based on a list of names in names.lst



      **name.lst**
      100GV200.vcf
      150GV200.vcf
      14300GV200.vcf

      **file.lst**
      file1.txt
      file2.txt
      file3.txt


      My script so far looks like this:



      parallel --link -k "cp {} {}" :::: file.lst :::: name.lst


      Unfortunately I get back:



       cp: target `100GV200.vcf` is not a directory


      When I run a single cp command in the terminal it works perfectly



      cp file1.txt 100GV200.vcf


      Where am I going wrong in understanding how GNU parallel reads in arguments?







      gnu-parallel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 9 at 1:02









      AMBAMB

      254




      254






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Use {1} and {2} notation:



          parallel --link -k cp {1} {2} :::: file.lst :::: name.lst


          Works for me, it will work with the quotes as well



          parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst


          To get it to work with {}, you would have had to do something like this:



          parallel --link -k "cp {}" :::: file.lst :::: name.lst


          Because parallel will automatically append the line of the two files.






          share|improve this answer


























          • Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

            – AMB
            Feb 9 at 1:36











          • If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

            – NiteRain
            Feb 9 at 1:50



















          1














          Don't bother with parallel's deranged interface; for file names without special characters you can just go for



          paste file.lst name.lst | xargs -n2 echo mv





          share|improve this answer































            0














            I have used below command to achieve the same



            paste file.lst name.lst|  awk '{print "cp" " " $1 " " $2}'|sh





            share|improve this answer























              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%2f499590%2fcopying-renaming-files-with-gnu-parallel%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Use {1} and {2} notation:



              parallel --link -k cp {1} {2} :::: file.lst :::: name.lst


              Works for me, it will work with the quotes as well



              parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst


              To get it to work with {}, you would have had to do something like this:



              parallel --link -k "cp {}" :::: file.lst :::: name.lst


              Because parallel will automatically append the line of the two files.






              share|improve this answer


























              • Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

                – AMB
                Feb 9 at 1:36











              • If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

                – NiteRain
                Feb 9 at 1:50
















              1














              Use {1} and {2} notation:



              parallel --link -k cp {1} {2} :::: file.lst :::: name.lst


              Works for me, it will work with the quotes as well



              parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst


              To get it to work with {}, you would have had to do something like this:



              parallel --link -k "cp {}" :::: file.lst :::: name.lst


              Because parallel will automatically append the line of the two files.






              share|improve this answer


























              • Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

                – AMB
                Feb 9 at 1:36











              • If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

                – NiteRain
                Feb 9 at 1:50














              1












              1








              1







              Use {1} and {2} notation:



              parallel --link -k cp {1} {2} :::: file.lst :::: name.lst


              Works for me, it will work with the quotes as well



              parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst


              To get it to work with {}, you would have had to do something like this:



              parallel --link -k "cp {}" :::: file.lst :::: name.lst


              Because parallel will automatically append the line of the two files.






              share|improve this answer















              Use {1} and {2} notation:



              parallel --link -k cp {1} {2} :::: file.lst :::: name.lst


              Works for me, it will work with the quotes as well



              parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst


              To get it to work with {}, you would have had to do something like this:



              parallel --link -k "cp {}" :::: file.lst :::: name.lst


              Because parallel will automatically append the line of the two files.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Feb 9 at 1:57

























              answered Feb 9 at 1:31









              NiteRainNiteRain

              23514




              23514













              • Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

                – AMB
                Feb 9 at 1:36











              • If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

                – NiteRain
                Feb 9 at 1:50



















              • Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

                – AMB
                Feb 9 at 1:36











              • If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

                – NiteRain
                Feb 9 at 1:50

















              Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

              – AMB
              Feb 9 at 1:36





              Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst

              – AMB
              Feb 9 at 1:36













              If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

              – NiteRain
              Feb 9 at 1:50





              If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.

              – NiteRain
              Feb 9 at 1:50













              1














              Don't bother with parallel's deranged interface; for file names without special characters you can just go for



              paste file.lst name.lst | xargs -n2 echo mv





              share|improve this answer




























                1














                Don't bother with parallel's deranged interface; for file names without special characters you can just go for



                paste file.lst name.lst | xargs -n2 echo mv





                share|improve this answer


























                  1












                  1








                  1







                  Don't bother with parallel's deranged interface; for file names without special characters you can just go for



                  paste file.lst name.lst | xargs -n2 echo mv





                  share|improve this answer













                  Don't bother with parallel's deranged interface; for file names without special characters you can just go for



                  paste file.lst name.lst | xargs -n2 echo mv






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 9 at 1:20









                  n.cailloun.caillou

                  30816




                  30816























                      0














                      I have used below command to achieve the same



                      paste file.lst name.lst|  awk '{print "cp" " " $1 " " $2}'|sh





                      share|improve this answer




























                        0














                        I have used below command to achieve the same



                        paste file.lst name.lst|  awk '{print "cp" " " $1 " " $2}'|sh





                        share|improve this answer


























                          0












                          0








                          0







                          I have used below command to achieve the same



                          paste file.lst name.lst|  awk '{print "cp" " " $1 " " $2}'|sh





                          share|improve this answer













                          I have used below command to achieve the same



                          paste file.lst name.lst|  awk '{print "cp" " " $1 " " $2}'|sh






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 9 at 3:58









                          Praveen Kumar BSPraveen Kumar BS

                          1,490138




                          1,490138






























                              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%2f499590%2fcopying-renaming-files-with-gnu-parallel%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 make a Squid Proxy server?

                              Is this a new Fibonacci Identity?

                              19世紀