Which command should I use to sum the values of two specific columns? For example, I have the file:
1 4 5 1
2 3 5 2
7 8 6 3
And I want to sum the second and last columns, to have the following result
1 4 5 1 5
2 3 5 2 5
7 8 6 3 11
shoud I use awk and bc? I have found many examples to sum the entire column...
Try:
awk '{print $0, $2 + $NF }' input_file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With