How to obtain only positive value in second column [on hold]












3















I use this command



awk 'NR%2{t=$1;next}{print $1-t,$2}'


to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.



1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51









share|improve this question















put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

    – Kusalananda
    2 days ago
















3















I use this command



awk 'NR%2{t=$1;next}{print $1-t,$2}'


to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.



1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51









share|improve this question















put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

    – Kusalananda
    2 days ago














3












3








3








I use this command



awk 'NR%2{t=$1;next}{print $1-t,$2}'


to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.



1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51









share|improve this question
















I use this command



awk 'NR%2{t=$1;next}{print $1-t,$2}'


to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.



1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51






awk numeric-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Jeff Schaller

44k1161142




44k1161142










asked 2 days ago









newstudentnewstudent

262




262




put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2





    It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

    – Kusalananda
    2 days ago














  • 2





    It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

    – Kusalananda
    2 days ago








2




2





It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

– Kusalananda
2 days ago





It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.

– Kusalananda
2 days ago










2 Answers
2






active

oldest

votes


















2














Command: awk '$2 !~ /^-/{print $0}' file

output

1577.57 47
1578.87 49
1580.15 51





share|improve this answer































    3














    You can replace this:



    {print $1-t,$2}


    with this:



    {if ($2>=0) print $1-t,$2}


    or,



    $2 >= 0 { print $1 - t, $2 }





    share|improve this answer
































      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      Command: awk '$2 !~ /^-/{print $0}' file

      output

      1577.57 47
      1578.87 49
      1580.15 51





      share|improve this answer




























        2














        Command: awk '$2 !~ /^-/{print $0}' file

        output

        1577.57 47
        1578.87 49
        1580.15 51





        share|improve this answer


























          2












          2








          2







          Command: awk '$2 !~ /^-/{print $0}' file

          output

          1577.57 47
          1578.87 49
          1580.15 51





          share|improve this answer













          Command: awk '$2 !~ /^-/{print $0}' file

          output

          1577.57 47
          1578.87 49
          1580.15 51






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Praveen Kumar BSPraveen Kumar BS

          1,6821311




          1,6821311

























              3














              You can replace this:



              {print $1-t,$2}


              with this:



              {if ($2>=0) print $1-t,$2}


              or,



              $2 >= 0 { print $1 - t, $2 }





              share|improve this answer






























                3














                You can replace this:



                {print $1-t,$2}


                with this:



                {if ($2>=0) print $1-t,$2}


                or,



                $2 >= 0 { print $1 - t, $2 }





                share|improve this answer




























                  3












                  3








                  3







                  You can replace this:



                  {print $1-t,$2}


                  with this:



                  {if ($2>=0) print $1-t,$2}


                  or,



                  $2 >= 0 { print $1 - t, $2 }





                  share|improve this answer















                  You can replace this:



                  {print $1-t,$2}


                  with this:



                  {if ($2>=0) print $1-t,$2}


                  or,



                  $2 >= 0 { print $1 - t, $2 }






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago









                  Kusalananda

                  138k17258426




                  138k17258426










                  answered 2 days ago









                  Romeo NinovRomeo Ninov

                  6,86432129




                  6,86432129















                      Popular posts from this blog

                      Category:香港粉麵

                      List *all* the tuples!

                      Channel [V]