AIX Unix Replicate data referencing a variable

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











up vote
0
down vote

favorite












I am using unix on AIX.



I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.



Example with 2 rows.



Product Number|Pick Qty|Unit of Issue|
13011|5|C|
566666|2|I|


The result I am after, is to use the Pick Qty value as the multiplying variable.
(This Pick Qty value will always be within the same position within the file, or column within a table.)



13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
566666|2|I|
566666|2|I|






share|improve this question

























    up vote
    0
    down vote

    favorite












    I am using unix on AIX.



    I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.



    Example with 2 rows.



    Product Number|Pick Qty|Unit of Issue|
    13011|5|C|
    566666|2|I|


    The result I am after, is to use the Pick Qty value as the multiplying variable.
    (This Pick Qty value will always be within the same position within the file, or column within a table.)



    13011|5|C|
    13011|5|C|
    13011|5|C|
    13011|5|C|
    13011|5|C|
    566666|2|I|
    566666|2|I|






    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am using unix on AIX.



      I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.



      Example with 2 rows.



      Product Number|Pick Qty|Unit of Issue|
      13011|5|C|
      566666|2|I|


      The result I am after, is to use the Pick Qty value as the multiplying variable.
      (This Pick Qty value will always be within the same position within the file, or column within a table.)



      13011|5|C|
      13011|5|C|
      13011|5|C|
      13011|5|C|
      13011|5|C|
      566666|2|I|
      566666|2|I|






      share|improve this question













      I am using unix on AIX.



      I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.



      Example with 2 rows.



      Product Number|Pick Qty|Unit of Issue|
      13011|5|C|
      566666|2|I|


      The result I am after, is to use the Pick Qty value as the multiplying variable.
      (This Pick Qty value will always be within the same position within the file, or column within a table.)



      13011|5|C|
      13011|5|C|
      13011|5|C|
      13011|5|C|
      13011|5|C|
      566666|2|I|
      566666|2|I|








      share|improve this question












      share|improve this question




      share|improve this question








      edited May 10 at 5:21









      Debian_yadav

      8342522




      8342522









      asked May 10 at 2:02









      Christian

      11




      11




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          try



          awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b


          where




          • -F| use | as separator (you must escape it)


          • NR==1 print print header (first line)


          • NR>1for(i=$2;i>0;i--) print for all remaining line, print then $2 time.





          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%2f442901%2faix-unix-replicate-data-referencing-a-variable%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
            1
            down vote













            try



            awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b


            where




            • -F| use | as separator (you must escape it)


            • NR==1 print print header (first line)


            • NR>1for(i=$2;i>0;i--) print for all remaining line, print then $2 time.





            share|improve this answer

























              up vote
              1
              down vote













              try



              awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b


              where




              • -F| use | as separator (you must escape it)


              • NR==1 print print header (first line)


              • NR>1for(i=$2;i>0;i--) print for all remaining line, print then $2 time.





              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                try



                awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b


                where




                • -F| use | as separator (you must escape it)


                • NR==1 print print header (first line)


                • NR>1for(i=$2;i>0;i--) print for all remaining line, print then $2 time.





                share|improve this answer













                try



                awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b


                where




                • -F| use | as separator (you must escape it)


                • NR==1 print print header (first line)


                • NR>1for(i=$2;i>0;i--) print for all remaining line, print then $2 time.






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered May 10 at 7:15









                Archemar

                18.9k93365




                18.9k93365






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442901%2faix-unix-replicate-data-referencing-a-variable%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)