Using GAWK to sum certain numbers line by line

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











up vote
1
down vote

favorite












My lines will look as such



X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0


Using GNU awk, how do I print (X-XX) + (Y-YY) on the end of every line?
Just to complicate things I need the () numbers to always be converted to plain numbers ie strip the negatives.

Looking to "mark" lines that the ending sum is greater than say 1.







share|improve this question






















  • 1) format your description; 2) post the expected final result
    – RomanPerekhrest
    Apr 11 at 14:54











  • What are () numbers?
    – glenn jackman
    Apr 11 at 16:31










  • Ideally ouput would be-
    – Lance Humbert
    Apr 11 at 19:26










  • Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
    – Lance Humbert
    Apr 11 at 19:32















up vote
1
down vote

favorite












My lines will look as such



X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0


Using GNU awk, how do I print (X-XX) + (Y-YY) on the end of every line?
Just to complicate things I need the () numbers to always be converted to plain numbers ie strip the negatives.

Looking to "mark" lines that the ending sum is greater than say 1.







share|improve this question






















  • 1) format your description; 2) post the expected final result
    – RomanPerekhrest
    Apr 11 at 14:54











  • What are () numbers?
    – glenn jackman
    Apr 11 at 16:31










  • Ideally ouput would be-
    – Lance Humbert
    Apr 11 at 19:26










  • Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
    – Lance Humbert
    Apr 11 at 19:32













up vote
1
down vote

favorite









up vote
1
down vote

favorite











My lines will look as such



X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0


Using GNU awk, how do I print (X-XX) + (Y-YY) on the end of every line?
Just to complicate things I need the () numbers to always be converted to plain numbers ie strip the negatives.

Looking to "mark" lines that the ending sum is greater than say 1.







share|improve this question














My lines will look as such



X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0


Using GNU awk, how do I print (X-XX) + (Y-YY) on the end of every line?
Just to complicate things I need the () numbers to always be converted to plain numbers ie strip the negatives.

Looking to "mark" lines that the ending sum is greater than say 1.









share|improve this question













share|improve this question




share|improve this question








edited Apr 11 at 15:22









Kusalananda

102k13199316




102k13199316










asked Apr 11 at 14:48









Lance Humbert

61




61











  • 1) format your description; 2) post the expected final result
    – RomanPerekhrest
    Apr 11 at 14:54











  • What are () numbers?
    – glenn jackman
    Apr 11 at 16:31










  • Ideally ouput would be-
    – Lance Humbert
    Apr 11 at 19:26










  • Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
    – Lance Humbert
    Apr 11 at 19:32

















  • 1) format your description; 2) post the expected final result
    – RomanPerekhrest
    Apr 11 at 14:54











  • What are () numbers?
    – glenn jackman
    Apr 11 at 16:31










  • Ideally ouput would be-
    – Lance Humbert
    Apr 11 at 19:26










  • Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
    – Lance Humbert
    Apr 11 at 19:32
















1) format your description; 2) post the expected final result
– RomanPerekhrest
Apr 11 at 14:54





1) format your description; 2) post the expected final result
– RomanPerekhrest
Apr 11 at 14:54













What are () numbers?
– glenn jackman
Apr 11 at 16:31




What are () numbers?
– glenn jackman
Apr 11 at 16:31












Ideally ouput would be-
– Lance Humbert
Apr 11 at 19:26




Ideally ouput would be-
– Lance Humbert
Apr 11 at 19:26












Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
– Lance Humbert
Apr 11 at 19:32





Ideally ouput would be-" X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 Q 0.010406897 Q being (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)
– Lance Humbert
Apr 11 at 19:32











1 Answer
1






active

oldest

votes

















up vote
0
down vote













$ awk ' print $0, "("$2"-"$8") + ("$4"-"$10")"' inputfile
X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)





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%2f437040%2fusing-gawk-to-sum-certain-numbers-line-by-line%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
    0
    down vote













    $ awk ' print $0, "("$2"-"$8") + ("$4"-"$10")"' inputfile
    X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)





    share|improve this answer
























      up vote
      0
      down vote













      $ awk ' print $0, "("$2"-"$8") + ("$4"-"$10")"' inputfile
      X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        $ awk ' print $0, "("$2"-"$8") + ("$4"-"$10")"' inputfile
        X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)





        share|improve this answer












        $ awk ' print $0, "("$2"-"$8") + ("$4"-"$10")"' inputfile
        X 2.63766751981802 Y 1.68326762144808 Z 0 XX 2.63577810877244 YY 1.67475013544567 ZZ 0 (2.63766751981802-2.63577810877244) + (1.68326762144808-1.67475013544567)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 11 at 16:13









        DopeGhoti

        40.1k54779




        40.1k54779






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f437040%2fusing-gawk-to-sum-certain-numbers-line-by-line%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?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay