Execute 2 or more remote scripts sharing the same curl pattern, without redundancy

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











up vote
1
down vote

favorite












I use Ubuntu 16.04 and I execute a list of remote scripts that are in the same directory (a GitHub repository):



curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh | tr -d 'r' | bash
curl -s https://raw.githubusercontent.com/$user/$repo/master/2.sh | tr -d 'r' | bash
curl -s https://raw.githubusercontent.com/$user/$repo/master/3.sh | tr -d 'r' | bash
curl -s https://raw.githubusercontent.com/$user/$repo/master/4.sh | tr -d 'r' | bash
curl -s https://raw.githubusercontent.com/$user/$repo/master/5.sh | tr -d 'r' | bash
curl -s https://raw.githubusercontent.com/$user/$repo/master/6.sh | tr -d 'r' | bash


How would you cope with the awful redundancy?



I think of a for loop but I have no idea how to construct it. All for loops I've seen so far doesn't give me a clue on how to do that particular task of reusing a curl pattern (and piped output) for different files in the same remote directory.



You are more than welcome to share an example.



Update



  • There might be more or less than six such curl operations.

  • I would use any plausible way but if it requires a utility please recommend a utility available in the Debian repositories.






share|improve this question


























    up vote
    1
    down vote

    favorite












    I use Ubuntu 16.04 and I execute a list of remote scripts that are in the same directory (a GitHub repository):



    curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh | tr -d 'r' | bash
    curl -s https://raw.githubusercontent.com/$user/$repo/master/2.sh | tr -d 'r' | bash
    curl -s https://raw.githubusercontent.com/$user/$repo/master/3.sh | tr -d 'r' | bash
    curl -s https://raw.githubusercontent.com/$user/$repo/master/4.sh | tr -d 'r' | bash
    curl -s https://raw.githubusercontent.com/$user/$repo/master/5.sh | tr -d 'r' | bash
    curl -s https://raw.githubusercontent.com/$user/$repo/master/6.sh | tr -d 'r' | bash


    How would you cope with the awful redundancy?



    I think of a for loop but I have no idea how to construct it. All for loops I've seen so far doesn't give me a clue on how to do that particular task of reusing a curl pattern (and piped output) for different files in the same remote directory.



    You are more than welcome to share an example.



    Update



    • There might be more or less than six such curl operations.

    • I would use any plausible way but if it requires a utility please recommend a utility available in the Debian repositories.






    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I use Ubuntu 16.04 and I execute a list of remote scripts that are in the same directory (a GitHub repository):



      curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/2.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/3.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/4.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/5.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/6.sh | tr -d 'r' | bash


      How would you cope with the awful redundancy?



      I think of a for loop but I have no idea how to construct it. All for loops I've seen so far doesn't give me a clue on how to do that particular task of reusing a curl pattern (and piped output) for different files in the same remote directory.



      You are more than welcome to share an example.



      Update



      • There might be more or less than six such curl operations.

      • I would use any plausible way but if it requires a utility please recommend a utility available in the Debian repositories.






      share|improve this question














      I use Ubuntu 16.04 and I execute a list of remote scripts that are in the same directory (a GitHub repository):



      curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/2.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/3.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/4.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/5.sh | tr -d 'r' | bash
      curl -s https://raw.githubusercontent.com/$user/$repo/master/6.sh | tr -d 'r' | bash


      How would you cope with the awful redundancy?



      I think of a for loop but I have no idea how to construct it. All for loops I've seen so far doesn't give me a clue on how to do that particular task of reusing a curl pattern (and piped output) for different files in the same remote directory.



      You are more than welcome to share an example.



      Update



      • There might be more or less than six such curl operations.

      • I would use any plausible way but if it requires a utility please recommend a utility available in the Debian repositories.








      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 9 at 17:45

























      asked Feb 9 at 12:11









      user9303970

      123224




      123224




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          For two or more files you could use Unix seq:



          for var in $(seq 6)
          do
          curl -s https://raw.githubusercontent.com/$user/$repo/master/$var.sh | tr -d 'r' | bash
          done


          Explanation:



          1. Use the output of seq to attain a count up to 6 (as the question lists 6 curl operations).

          2. Read the output into the variable var and use this in your curl command.





          share|improve this answer


















          • 1




            double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
            – cas
            Feb 9 at 13:52










          • Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
            – user9303970
            Feb 9 at 15:05










          • Yes, you can change it to what ever you want
            – Raman Sailopal
            Feb 9 at 15:32










          • Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
            – user9303970
            Feb 9 at 16:48

















          up vote
          3
          down vote













          The fastest one with GNU parallel:



          parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh 
          | tr -d 'r' | bash" ::: 1..6



          You may also specify the crucial number via dynamic variable:



          n=7
          parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh
          | tr -d 'r' | bash" ::: $(seq $n)


          https://www.gnu.org/software/parallel/man.html






          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f423029%2fexecute-2-or-more-remote-scripts-sharing-the-same-curl-pattern-without-redundan%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            For two or more files you could use Unix seq:



            for var in $(seq 6)
            do
            curl -s https://raw.githubusercontent.com/$user/$repo/master/$var.sh | tr -d 'r' | bash
            done


            Explanation:



            1. Use the output of seq to attain a count up to 6 (as the question lists 6 curl operations).

            2. Read the output into the variable var and use this in your curl command.





            share|improve this answer


















            • 1




              double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
              – cas
              Feb 9 at 13:52










            • Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
              – user9303970
              Feb 9 at 15:05










            • Yes, you can change it to what ever you want
              – Raman Sailopal
              Feb 9 at 15:32










            • Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
              – user9303970
              Feb 9 at 16:48














            up vote
            4
            down vote



            accepted










            For two or more files you could use Unix seq:



            for var in $(seq 6)
            do
            curl -s https://raw.githubusercontent.com/$user/$repo/master/$var.sh | tr -d 'r' | bash
            done


            Explanation:



            1. Use the output of seq to attain a count up to 6 (as the question lists 6 curl operations).

            2. Read the output into the variable var and use this in your curl command.





            share|improve this answer


















            • 1




              double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
              – cas
              Feb 9 at 13:52










            • Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
              – user9303970
              Feb 9 at 15:05










            • Yes, you can change it to what ever you want
              – Raman Sailopal
              Feb 9 at 15:32










            • Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
              – user9303970
              Feb 9 at 16:48












            up vote
            4
            down vote



            accepted







            up vote
            4
            down vote



            accepted






            For two or more files you could use Unix seq:



            for var in $(seq 6)
            do
            curl -s https://raw.githubusercontent.com/$user/$repo/master/$var.sh | tr -d 'r' | bash
            done


            Explanation:



            1. Use the output of seq to attain a count up to 6 (as the question lists 6 curl operations).

            2. Read the output into the variable var and use this in your curl command.





            share|improve this answer














            For two or more files you could use Unix seq:



            for var in $(seq 6)
            do
            curl -s https://raw.githubusercontent.com/$user/$repo/master/$var.sh | tr -d 'r' | bash
            done


            Explanation:



            1. Use the output of seq to attain a count up to 6 (as the question lists 6 curl operations).

            2. Read the output into the variable var and use this in your curl command.






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 9 at 17:54









            Community♦

            1




            1










            answered Feb 9 at 12:29









            Raman Sailopal

            1,18117




            1,18117







            • 1




              double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
              – cas
              Feb 9 at 13:52










            • Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
              – user9303970
              Feb 9 at 15:05










            • Yes, you can change it to what ever you want
              – Raman Sailopal
              Feb 9 at 15:32










            • Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
              – user9303970
              Feb 9 at 16:48












            • 1




              double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
              – cas
              Feb 9 at 13:52










            • Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
              – user9303970
              Feb 9 at 15:05










            • Yes, you can change it to what ever you want
              – Raman Sailopal
              Feb 9 at 15:32










            • Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
              – user9303970
              Feb 9 at 16:48







            1




            1




            double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
            – cas
            Feb 9 at 13:52




            double quote your variables when you use them - $user or $repo could contain spaces, tabs, or shell metacharacters. In this case, just double-quote the entire URL string: curl -s "https://raw.githubusercontent.com/$user/$repo/master/$var.sh" | tr ...
            – cas
            Feb 9 at 13:52












            Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
            – user9303970
            Feb 9 at 15:05




            Is the seq 6 an upper border? I could put it to say 10 if I had a range of 1-10 files?
            – user9303970
            Feb 9 at 15:05












            Yes, you can change it to what ever you want
            – Raman Sailopal
            Feb 9 at 15:32




            Yes, you can change it to what ever you want
            – Raman Sailopal
            Feb 9 at 15:32












            Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
            – user9303970
            Feb 9 at 16:48




            Sure, just wanted to ensure it's a matter of range and not fixed number. Thanks!
            – user9303970
            Feb 9 at 16:48












            up vote
            3
            down vote













            The fastest one with GNU parallel:



            parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh 
            | tr -d 'r' | bash" ::: 1..6



            You may also specify the crucial number via dynamic variable:



            n=7
            parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh
            | tr -d 'r' | bash" ::: $(seq $n)


            https://www.gnu.org/software/parallel/man.html






            share|improve this answer


























              up vote
              3
              down vote













              The fastest one with GNU parallel:



              parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh 
              | tr -d 'r' | bash" ::: 1..6



              You may also specify the crucial number via dynamic variable:



              n=7
              parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh
              | tr -d 'r' | bash" ::: $(seq $n)


              https://www.gnu.org/software/parallel/man.html






              share|improve this answer
























                up vote
                3
                down vote










                up vote
                3
                down vote









                The fastest one with GNU parallel:



                parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh 
                | tr -d 'r' | bash" ::: 1..6



                You may also specify the crucial number via dynamic variable:



                n=7
                parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh
                | tr -d 'r' | bash" ::: $(seq $n)


                https://www.gnu.org/software/parallel/man.html






                share|improve this answer














                The fastest one with GNU parallel:



                parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh 
                | tr -d 'r' | bash" ::: 1..6



                You may also specify the crucial number via dynamic variable:



                n=7
                parallel -j0 -k "curl -s https://raw.githubusercontent.com/$user/$repo/master/1.sh
                | tr -d 'r' | bash" ::: $(seq $n)


                https://www.gnu.org/software/parallel/man.html







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 9 at 12:57

























                answered Feb 9 at 12:38









                RomanPerekhrest

                22.4k12144




                22.4k12144






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f423029%2fexecute-2-or-more-remote-scripts-sharing-the-same-curl-pattern-without-redundan%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)