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 22 hours 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
    yesterday
















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 22 hours 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
    yesterday














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 yesterday









Jeff Schaller

43.9k1161141




43.9k1161141










asked yesterday









newstudentnewstudent

262




262




put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 22 hours 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 22 hours 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
    yesterday














  • 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
    yesterday








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
yesterday





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
yesterday










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 yesterday









          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 yesterday









                  Kusalananda

                  138k17258426




                  138k17258426










                  answered yesterday









                  Romeo NinovRomeo Ninov

                  6,86432129




                  6,86432129















                      Popular posts from this blog

                      He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

                      Bunad

                      Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum