Way to specify param for all commands executed

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











up vote
3
down vote

favorite
1












I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.



sudo cmd1 cmd2 cm3 --help



this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?







share|improve this question


























    up vote
    3
    down vote

    favorite
    1












    I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.



    sudo cmd1 cmd2 cm3 --help



    this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?







    share|improve this question
























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.



      sudo cmd1 cmd2 cm3 --help



      this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?







      share|improve this question














      I was wondering if there is a way to specify a mutual param for X amount of commands. E.g.



      sudo cmd1 cmd2 cm3 --help



      this obviously doesn't work, but I haven't seen anything in the manual. I'm assuming it can't be done, but didn't rule it out completely. If it doesn't exist, how can I go about making it?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 6 '17 at 14:18









      terdon♦

      123k28231403




      123k28231403










      asked Nov 6 '17 at 14:06









      ThisGuyHasTwoThumbs

      1979




      1979




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          7
          down vote



          accepted










          You'd have to use a loop:



          for cmd in cmd1 cmd2 cmd3; do
          "$cmd" --help
          done


          Or write a little function for it (add this to your shell's initialization file, ~/.bashrc if using bash):



          runWithParam()
          param="$1"
          shift
          for cmd; do
          "$cmd" "$param"
          done



          Then, run it with the parameter as the first parameter of the function:



          runWithParam --help cmd1 cmd2 cmd3





          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%2f402835%2fway-to-specify-param-for-all-commands-executed%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            7
            down vote



            accepted










            You'd have to use a loop:



            for cmd in cmd1 cmd2 cmd3; do
            "$cmd" --help
            done


            Or write a little function for it (add this to your shell's initialization file, ~/.bashrc if using bash):



            runWithParam()
            param="$1"
            shift
            for cmd; do
            "$cmd" "$param"
            done



            Then, run it with the parameter as the first parameter of the function:



            runWithParam --help cmd1 cmd2 cmd3





            share|improve this answer


























              up vote
              7
              down vote



              accepted










              You'd have to use a loop:



              for cmd in cmd1 cmd2 cmd3; do
              "$cmd" --help
              done


              Or write a little function for it (add this to your shell's initialization file, ~/.bashrc if using bash):



              runWithParam()
              param="$1"
              shift
              for cmd; do
              "$cmd" "$param"
              done



              Then, run it with the parameter as the first parameter of the function:



              runWithParam --help cmd1 cmd2 cmd3





              share|improve this answer
























                up vote
                7
                down vote



                accepted







                up vote
                7
                down vote



                accepted






                You'd have to use a loop:



                for cmd in cmd1 cmd2 cmd3; do
                "$cmd" --help
                done


                Or write a little function for it (add this to your shell's initialization file, ~/.bashrc if using bash):



                runWithParam()
                param="$1"
                shift
                for cmd; do
                "$cmd" "$param"
                done



                Then, run it with the parameter as the first parameter of the function:



                runWithParam --help cmd1 cmd2 cmd3





                share|improve this answer














                You'd have to use a loop:



                for cmd in cmd1 cmd2 cmd3; do
                "$cmd" --help
                done


                Or write a little function for it (add this to your shell's initialization file, ~/.bashrc if using bash):



                runWithParam()
                param="$1"
                shift
                for cmd; do
                "$cmd" "$param"
                done



                Then, run it with the parameter as the first parameter of the function:



                runWithParam --help cmd1 cmd2 cmd3






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 6 '17 at 14:14









                user4556274

                4,97811123




                4,97811123










                answered Nov 6 '17 at 14:12









                terdon♦

                123k28231403




                123k28231403



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402835%2fway-to-specify-param-for-all-commands-executed%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?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?