How do I extract a number from a row

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











up vote
0
down vote

favorite












31400 371 2946 3966 12378 82 185 206 46 1


I want to write a script that will always extract the second number from a script like the one above i.e. 371. The number changes each time I run the script. Any ideas what bash command to use to extract just the number 371 but that number could be anything.










share|improve this question



























    up vote
    0
    down vote

    favorite












    31400 371 2946 3966 12378 82 185 206 46 1


    I want to write a script that will always extract the second number from a script like the one above i.e. 371. The number changes each time I run the script. Any ideas what bash command to use to extract just the number 371 but that number could be anything.










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      31400 371 2946 3966 12378 82 185 206 46 1


      I want to write a script that will always extract the second number from a script like the one above i.e. 371. The number changes each time I run the script. Any ideas what bash command to use to extract just the number 371 but that number could be anything.










      share|improve this question















      31400 371 2946 3966 12378 82 185 206 46 1


      I want to write a script that will always extract the second number from a script like the one above i.e. 371. The number changes each time I run the script. Any ideas what bash command to use to extract just the number 371 but that number could be anything.







      text-processing awk sed numeric-data






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 23 at 16:07









      Jeff Schaller

      32.7k849110




      32.7k849110










      asked Aug 23 at 15:40









      Keiran Corbett

      1




      1




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote













          This is exactly the sort of thing that awk is for:



          $ ./yourscript.sh | awk 'print $2'
          371





          share|improve this answer



























            up vote
            0
            down vote













            Or



            cut -f2 file


            presumed the data are Tab separated.






            share|improve this answer





























              up vote
              0
              down vote













              Or



              ./yourscript.sh | read a b c; echo $b; 





              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%2f464435%2fhow-do-i-extract-a-number-from-a-row%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                This is exactly the sort of thing that awk is for:



                $ ./yourscript.sh | awk 'print $2'
                371





                share|improve this answer
























                  up vote
                  4
                  down vote













                  This is exactly the sort of thing that awk is for:



                  $ ./yourscript.sh | awk 'print $2'
                  371





                  share|improve this answer






















                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    This is exactly the sort of thing that awk is for:



                    $ ./yourscript.sh | awk 'print $2'
                    371





                    share|improve this answer












                    This is exactly the sort of thing that awk is for:



                    $ ./yourscript.sh | awk 'print $2'
                    371






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 23 at 15:42









                    DopeGhoti

                    41.1k55080




                    41.1k55080






















                        up vote
                        0
                        down vote













                        Or



                        cut -f2 file


                        presumed the data are Tab separated.






                        share|improve this answer


























                          up vote
                          0
                          down vote













                          Or



                          cut -f2 file


                          presumed the data are Tab separated.






                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Or



                            cut -f2 file


                            presumed the data are Tab separated.






                            share|improve this answer














                            Or



                            cut -f2 file


                            presumed the data are Tab separated.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Aug 23 at 16:43









                            αғsнιη

                            15.8k92563




                            15.8k92563










                            answered Aug 23 at 16:27









                            RudiC

                            1,2168




                            1,2168




















                                up vote
                                0
                                down vote













                                Or



                                ./yourscript.sh | read a b c; echo $b; 





                                share|improve this answer


























                                  up vote
                                  0
                                  down vote













                                  Or



                                  ./yourscript.sh | read a b c; echo $b; 





                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    Or



                                    ./yourscript.sh | read a b c; echo $b; 





                                    share|improve this answer














                                    Or



                                    ./yourscript.sh | read a b c; echo $b; 






                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Aug 24 at 10:07









                                    Jeff Schaller

                                    32.7k849110




                                    32.7k849110










                                    answered Aug 24 at 7:33









                                    Michael Vehrs

                                    2,17037




                                    2,17037



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464435%2fhow-do-i-extract-a-number-from-a-row%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?