Uniting urls for a download utility (like wget) in one line

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











up vote
4
down vote

favorite












Consider these wget codes:



wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh


Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?



Pseudocode:



wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh






share|improve this question


























    up vote
    4
    down vote

    favorite












    Consider these wget codes:



    wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
    wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh


    Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?



    Pseudocode:



    wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh






    share|improve this question
























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      Consider these wget codes:



      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh


      Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?



      Pseudocode:



      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh






      share|improve this question














      Consider these wget codes:



      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh


      Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?



      Pseudocode:



      wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh








      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 14 at 5:51

























      asked Jan 13 at 19:51









      Arcticooling

      83123




      83123




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          As wget accepts several URLs at once this can be done using brace expansion in bash:



          wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh


          (or even



          wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh


          but this only works for well-suited names of course).






          share|improve this answer




















          • Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
            – Arcticooling
            Jan 13 at 20:00







          • 1




            @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
            – nohillside
            Jan 13 at 20:07










          • "this only works for well-suited names" – What names do you think it would not work for?
            – Hauke Laging
            Jan 13 at 20:24






          • 1




            @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
            – nohillside
            Jan 13 at 21:19










          • @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
            – JoL
            Jan 14 at 5:11


















          up vote
          0
          down vote













          I have done this by using awk command and for loop. Let me know for any doubts and confusion



          Created one file example.txt by putting below content in a file



          cat example.txt



          wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/


          I have assigned papj.sh nixta.sh to the variable i



          Used below script to execute as per your requirement



          for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done


          Output



          wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

          wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.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',
            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%2f416896%2funiting-urls-for-a-download-utility-like-wget-in-one-line%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
            8
            down vote



            accepted










            As wget accepts several URLs at once this can be done using brace expansion in bash:



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh


            (or even



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh


            but this only works for well-suited names of course).






            share|improve this answer




















            • Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
              – Arcticooling
              Jan 13 at 20:00







            • 1




              @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
              – nohillside
              Jan 13 at 20:07










            • "this only works for well-suited names" – What names do you think it would not work for?
              – Hauke Laging
              Jan 13 at 20:24






            • 1




              @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
              – nohillside
              Jan 13 at 21:19










            • @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
              – JoL
              Jan 14 at 5:11















            up vote
            8
            down vote



            accepted










            As wget accepts several URLs at once this can be done using brace expansion in bash:



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh


            (or even



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh


            but this only works for well-suited names of course).






            share|improve this answer




















            • Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
              – Arcticooling
              Jan 13 at 20:00







            • 1




              @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
              – nohillside
              Jan 13 at 20:07










            • "this only works for well-suited names" – What names do you think it would not work for?
              – Hauke Laging
              Jan 13 at 20:24






            • 1




              @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
              – nohillside
              Jan 13 at 21:19










            • @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
              – JoL
              Jan 14 at 5:11













            up vote
            8
            down vote



            accepted







            up vote
            8
            down vote



            accepted






            As wget accepts several URLs at once this can be done using brace expansion in bash:



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh


            (or even



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh


            but this only works for well-suited names of course).






            share|improve this answer












            As wget accepts several URLs at once this can be done using brace expansion in bash:



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh


            (or even



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh


            but this only works for well-suited names of course).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 13 at 19:57









            nohillside

            1,868616




            1,868616











            • Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
              – Arcticooling
              Jan 13 at 20:00







            • 1




              @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
              – nohillside
              Jan 13 at 20:07










            • "this only works for well-suited names" – What names do you think it would not work for?
              – Hauke Laging
              Jan 13 at 20:24






            • 1




              @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
              – nohillside
              Jan 13 at 21:19










            • @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
              – JoL
              Jan 14 at 5:11

















            • Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
              – Arcticooling
              Jan 13 at 20:00







            • 1




              @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
              – nohillside
              Jan 13 at 20:07










            • "this only works for well-suited names" – What names do you think it would not work for?
              – Hauke Laging
              Jan 13 at 20:24






            • 1




              @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
              – nohillside
              Jan 13 at 21:19










            • @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
              – JoL
              Jan 14 at 5:11
















            Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
            – Arcticooling
            Jan 13 at 20:00





            Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
            – Arcticooling
            Jan 13 at 20:00





            1




            1




            @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
            – nohillside
            Jan 13 at 20:07




            @Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/… has some good examples, I use the cp /path/to/file,.bak thing regularly (but mostly interactively, not in scripts).
            – nohillside
            Jan 13 at 20:07












            "this only works for well-suited names" – What names do you think it would not work for?
            – Hauke Laging
            Jan 13 at 20:24




            "this only works for well-suited names" – What names do you think it would not work for?
            – Hauke Laging
            Jan 13 at 20:24




            1




            1




            @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
            – nohillside
            Jan 13 at 21:19




            @HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
            – nohillside
            Jan 13 at 21:19












            @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
            – JoL
            Jan 14 at 5:11





            @patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do wget http://example.com/img-1..70.jpg or similar to download them all.
            – JoL
            Jan 14 at 5:11













            up vote
            0
            down vote













            I have done this by using awk command and for loop. Let me know for any doubts and confusion



            Created one file example.txt by putting below content in a file



            cat example.txt



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/


            I have assigned papj.sh nixta.sh to the variable i



            Used below script to execute as per your requirement



            for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done


            Output



            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

            wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh





            share|improve this answer
























              up vote
              0
              down vote













              I have done this by using awk command and for loop. Let me know for any doubts and confusion



              Created one file example.txt by putting below content in a file



              cat example.txt



              wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/


              I have assigned papj.sh nixta.sh to the variable i



              Used below script to execute as per your requirement



              for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done


              Output



              wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

              wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh





              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                I have done this by using awk command and for loop. Let me know for any doubts and confusion



                Created one file example.txt by putting below content in a file



                cat example.txt



                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/


                I have assigned papj.sh nixta.sh to the variable i



                Used below script to execute as per your requirement



                for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done


                Output



                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh





                share|improve this answer












                I have done this by using awk command and for loop. Let me know for any doubts and confusion



                Created one file example.txt by putting below content in a file



                cat example.txt



                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/


                I have assigned papj.sh nixta.sh to the variable i



                Used below script to execute as per your requirement



                for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done


                Output



                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh

                wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 14 at 12:20









                Praveen Kumar BS

                1,010128




                1,010128






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416896%2funiting-urls-for-a-download-utility-like-wget-in-one-line%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

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

                    Christian Cage

                    How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?