Reputation: 3
I would like to subtract 2 numbers in this line and have the result at the end of the line, like this example:
numbers ; 20.55 ; 10.55
so I have the result
numbers ; 20.55 ; 10.55 ; -10
What is the easiest way to do this?
Upvotes: 0
Views: 40
Reputation: 26667
awk
would be a better tool than sed
for this purpose
awk -F\; '{print $0, $3-$2}' OFS=" ; "
Example
$ awk -F\; '{print $0, $3-$2}' OFS=" ; " input
numbers ; 20.55 ; 10.55 ; -10
Upvotes: 1