how to increment aplha numeric number field in awkAwk remove field only if numericHow to print matching value...

Multi tool use
Multi tool use

How do credit card companies know what type of business I'm paying for?

Creating polygon with exact measurements in QGIS 3

Is it a bad idea to have an pen name with only an initial for a surname?

Someone who is granted access to information but not expected to read it

newcommand with parameter blank or zero

Co-worker is now managing my team. Does this mean that I'm being demoted?

Idiom for 'person who gets violent when drunk"

100-doors puzzle

Is it possible for underground bunkers on different continents to be connected?

Leveraging cash for buying car

Why is gun control associated with the socially liberal Democratic party?

Will users know a CardView is clickable

How can this shape perfectly cover a cube?

How can I improve readability and length of a method with many if statements?

Arcane Tradition and Cost Efficiency: Learn spells on level-up, or learn them from scrolls/spellbooks?

Leveling up and Getting Items!

VHDL: What is correct way to model open collector output for FPGA?

Does an African-American baby born in Youngstown, Ohio have a higher infant mortality rate than a baby born in Iran?

Are there any rules for identifying what spell an opponent is casting?

Is it possible to install Firefox on Ubuntu with no desktop enviroment?

Why not make one big CPU core?

Cremated People Pottery

Basic power tool set for Home repair and simple projects

Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?



how to increment aplha numeric number field in awk


Awk remove field only if numericHow to print matching value of patterned field separator in AWKFind the number FN with awkAwk Using NR to output iteration numberawk edit column value if numericHow to increment column using AWKhow to delete duplicate number from row?Insert a line break before a numeric field or before an alphanumeric field that is just after a numeric fieldusing awk to modify field with conditionMake awk produce error on non-numeric






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















i want to incerement M152DHD3H4M2 this number.



output like



M152DHD3H4M3
M152DHD3H4M4
M152DHD3H4M5
M152DHD3H4M6









share|improve this question









New contributor



user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    i want to incerement M152DHD3H4M2 this number.



    output like



    M152DHD3H4M3
    M152DHD3H4M4
    M152DHD3H4M5
    M152DHD3H4M6









    share|improve this question









    New contributor



    user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      i want to incerement M152DHD3H4M2 this number.



      output like



      M152DHD3H4M3
      M152DHD3H4M4
      M152DHD3H4M5
      M152DHD3H4M6









      share|improve this question









      New contributor



      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      i want to incerement M152DHD3H4M2 this number.



      output like



      M152DHD3H4M3
      M152DHD3H4M4
      M152DHD3H4M5
      M152DHD3H4M6






      awk






      share|improve this question









      New contributor



      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 50 mins ago









      muru

      39.6k595171




      39.6k595171






      New contributor



      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 1 hour ago









      user357790user357790

      1




      1




      New contributor



      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      user357790 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Method 1: Treat each character as a separate field



          $ echo 'M152DHD3H4M2' | awk -F "" '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=
          M152DHD3H4M3
          M152DHD3H4M4
          M152DHD3H4M5
          M152DHD3H4M6


          -F "" tells awk to treat each character as separate field on input and OFS= tells awk not to add any field separator on output. We then increment the last field as desired.



          An empty field separator like this is not required by POSIX but is supported by at least by GNU awk and mawk.



          Method 2: Use M as a field separator



          $ echo 'M152DHD3H4M2' | awk -FM '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=M
          M152DHD3H4M3
          M152DHD3H4M4
          M152DHD3H4M5
          M152DHD3H4M6


          -FM and OFS=M tells awk to use M as the field separator on both input and output. We then increment the last field as desired.



          Method 3: Divide the string into parts using substr



          $ echo 'M152DHD3H4M2' | awk '{for(i=1;i<=4;i++) print substr($1, 1, length($1)-1) i+substr($1, length($1))}'
          M152DHD3H4M3
          M152DHD3H4M4
          M152DHD3H4M5
          M152DHD3H4M6


          Here we break the input line manually using the substring function, substr, and increment the last character as desired.






          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
            });


            }
            });






            user357790 is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524816%2fhow-to-increment-aplha-numeric-number-field-in-awk%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Method 1: Treat each character as a separate field



            $ echo 'M152DHD3H4M2' | awk -F "" '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=
            M152DHD3H4M3
            M152DHD3H4M4
            M152DHD3H4M5
            M152DHD3H4M6


            -F "" tells awk to treat each character as separate field on input and OFS= tells awk not to add any field separator on output. We then increment the last field as desired.



            An empty field separator like this is not required by POSIX but is supported by at least by GNU awk and mawk.



            Method 2: Use M as a field separator



            $ echo 'M152DHD3H4M2' | awk -FM '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=M
            M152DHD3H4M3
            M152DHD3H4M4
            M152DHD3H4M5
            M152DHD3H4M6


            -FM and OFS=M tells awk to use M as the field separator on both input and output. We then increment the last field as desired.



            Method 3: Divide the string into parts using substr



            $ echo 'M152DHD3H4M2' | awk '{for(i=1;i<=4;i++) print substr($1, 1, length($1)-1) i+substr($1, length($1))}'
            M152DHD3H4M3
            M152DHD3H4M4
            M152DHD3H4M5
            M152DHD3H4M6


            Here we break the input line manually using the substring function, substr, and increment the last character as desired.






            share|improve this answer






























              0














              Method 1: Treat each character as a separate field



              $ echo 'M152DHD3H4M2' | awk -F "" '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=
              M152DHD3H4M3
              M152DHD3H4M4
              M152DHD3H4M5
              M152DHD3H4M6


              -F "" tells awk to treat each character as separate field on input and OFS= tells awk not to add any field separator on output. We then increment the last field as desired.



              An empty field separator like this is not required by POSIX but is supported by at least by GNU awk and mawk.



              Method 2: Use M as a field separator



              $ echo 'M152DHD3H4M2' | awk -FM '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=M
              M152DHD3H4M3
              M152DHD3H4M4
              M152DHD3H4M5
              M152DHD3H4M6


              -FM and OFS=M tells awk to use M as the field separator on both input and output. We then increment the last field as desired.



              Method 3: Divide the string into parts using substr



              $ echo 'M152DHD3H4M2' | awk '{for(i=1;i<=4;i++) print substr($1, 1, length($1)-1) i+substr($1, length($1))}'
              M152DHD3H4M3
              M152DHD3H4M4
              M152DHD3H4M5
              M152DHD3H4M6


              Here we break the input line manually using the substring function, substr, and increment the last character as desired.






              share|improve this answer




























                0












                0








                0







                Method 1: Treat each character as a separate field



                $ echo 'M152DHD3H4M2' | awk -F "" '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                -F "" tells awk to treat each character as separate field on input and OFS= tells awk not to add any field separator on output. We then increment the last field as desired.



                An empty field separator like this is not required by POSIX but is supported by at least by GNU awk and mawk.



                Method 2: Use M as a field separator



                $ echo 'M152DHD3H4M2' | awk -FM '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=M
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                -FM and OFS=M tells awk to use M as the field separator on both input and output. We then increment the last field as desired.



                Method 3: Divide the string into parts using substr



                $ echo 'M152DHD3H4M2' | awk '{for(i=1;i<=4;i++) print substr($1, 1, length($1)-1) i+substr($1, length($1))}'
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                Here we break the input line manually using the substring function, substr, and increment the last character as desired.






                share|improve this answer















                Method 1: Treat each character as a separate field



                $ echo 'M152DHD3H4M2' | awk -F "" '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                -F "" tells awk to treat each character as separate field on input and OFS= tells awk not to add any field separator on output. We then increment the last field as desired.



                An empty field separator like this is not required by POSIX but is supported by at least by GNU awk and mawk.



                Method 2: Use M as a field separator



                $ echo 'M152DHD3H4M2' | awk -FM '{for(i=3;i<=6;i++) {$NF=i;print}}' OFS=M
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                -FM and OFS=M tells awk to use M as the field separator on both input and output. We then increment the last field as desired.



                Method 3: Divide the string into parts using substr



                $ echo 'M152DHD3H4M2' | awk '{for(i=1;i<=4;i++) print substr($1, 1, length($1)-1) i+substr($1, length($1))}'
                M152DHD3H4M3
                M152DHD3H4M4
                M152DHD3H4M5
                M152DHD3H4M6


                Here we break the input line manually using the substring function, substr, and increment the last character as desired.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 33 mins ago

























                answered 40 mins ago









                John1024John1024

                50.2k5117131




                50.2k5117131






















                    user357790 is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    user357790 is a new contributor. Be nice, and check out our Code of Conduct.













                    user357790 is a new contributor. Be nice, and check out our Code of Conduct.












                    user357790 is a new contributor. Be nice, and check out our Code of Conduct.
















                    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%2f524816%2fhow-to-increment-aplha-numeric-number-field-in-awk%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







                    ccbYj39HBiEf3 B,Nz4zpC8GwIHeJXa12,SC
                    xrVvM47XnW oBUg3QzNHrzybbYCbax9odhSchbdLFGxGdGJnX,iSpK4,zhf,v3ibt4S p,GyXZxu8

                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m

                    Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...