1

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.

  • 1) format your description; 2) post the expected final result – RomanPerekhrest Apr 11 '18 at 14:54
  • What are () numbers? – glenn jackman Apr 11 '18 at 16:31
  • Ideally ouput would be- – Lance Humbert Apr 11 '18 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 '18 at 19:32
0
$ 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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.