Using GAWK to sum certain numbers line by line
Clash 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.
sed gawk
add a comment |Â
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.
sed gawk
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
add a comment |Â
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.
sed gawk
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.
sed gawk
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
add a comment |Â
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
add a comment |Â
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)
add a comment |Â
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)
add a comment |Â
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)
add a comment |Â
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)
$ 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)
answered Apr 11 at 16:13
DopeGhoti
40.1k54779
40.1k54779
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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