Multiple substitution when repeating the previous command

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











up vote
0
down vote

favorite












I know that I can simply substitute a string with another in the previous command by typing:



!!:gs/string1/string2/


But how I can perform multiple substitutions, e.g. having a command:



echo "AAAAAAAAAAAAAAAAA" > test1


I want to substitute A with B and 1 with 2, so execute such a command:



echo "BBBBBBBBBBBBBBBBB" > test2


How can I do it with !! operator?







share|improve this question

























    up vote
    0
    down vote

    favorite












    I know that I can simply substitute a string with another in the previous command by typing:



    !!:gs/string1/string2/


    But how I can perform multiple substitutions, e.g. having a command:



    echo "AAAAAAAAAAAAAAAAA" > test1


    I want to substitute A with B and 1 with 2, so execute such a command:



    echo "BBBBBBBBBBBBBBBBB" > test2


    How can I do it with !! operator?







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I know that I can simply substitute a string with another in the previous command by typing:



      !!:gs/string1/string2/


      But how I can perform multiple substitutions, e.g. having a command:



      echo "AAAAAAAAAAAAAAAAA" > test1


      I want to substitute A with B and 1 with 2, so execute such a command:



      echo "BBBBBBBBBBBBBBBBB" > test2


      How can I do it with !! operator?







      share|improve this question













      I know that I can simply substitute a string with another in the previous command by typing:



      !!:gs/string1/string2/


      But how I can perform multiple substitutions, e.g. having a command:



      echo "AAAAAAAAAAAAAAAAA" > test1


      I want to substitute A with B and 1 with 2, so execute such a command:



      echo "BBBBBBBBBBBBBBBBB" > test2


      How can I do it with !! operator?









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 11 at 7:39









      Kusalananda

      101k13199312




      101k13199312









      asked Jul 11 at 7:30









      K. Koovalsky

      103




      103




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          $ echo "AAAAAAAAAAAAAAAAA" > test1
          $ !!:gs/A/B/:s/1/2/
          echo "BBBBBBBBBBBBBBBBB" > test2


          That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.






          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%2f454628%2fmultiple-substitution-when-repeating-the-previous-command%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
            3
            down vote



            accepted










            $ echo "AAAAAAAAAAAAAAAAA" > test1
            $ !!:gs/A/B/:s/1/2/
            echo "BBBBBBBBBBBBBBBBB" > test2


            That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.






            share|improve this answer



























              up vote
              3
              down vote



              accepted










              $ echo "AAAAAAAAAAAAAAAAA" > test1
              $ !!:gs/A/B/:s/1/2/
              echo "BBBBBBBBBBBBBBBBB" > test2


              That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.






              share|improve this answer

























                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                $ echo "AAAAAAAAAAAAAAAAA" > test1
                $ !!:gs/A/B/:s/1/2/
                echo "BBBBBBBBBBBBBBBBB" > test2


                That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.






                share|improve this answer















                $ echo "AAAAAAAAAAAAAAAAA" > test1
                $ !!:gs/A/B/:s/1/2/
                echo "BBBBBBBBBBBBBBBBB" > test2


                That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.







                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jul 11 at 7:44


























                answered Jul 11 at 7:36









                Kusalananda

                101k13199312




                101k13199312






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454628%2fmultiple-substitution-when-repeating-the-previous-command%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?