Hi,
I would like to show the difference between two numbers. For example.
input.txt
1 7
2 10
0 0
6 7
I would like a third field showing the difference between the numbers as below:
ouput.txt
1 7 6
2 10 8
0 0 0
6 7 1
How do I do this?
Thanks,
Hi,
I would like to show the difference between two numbers. For example.
input.txt
1 7
2 10
0 0
6 7
I would like a third field showing the difference between the numbers as below:
ouput.txt
1 7 6
2 10 8
0 0 0
6 7 1
How do I do this?
Thanks,
Is this homework?
What have you tried so far?
Which OS; shell, machine etc...
cat inputfile | while read a b
do
c=`expr $a - $b`
echo $a $b $c
done
Using Contos 6.4, bash shell on VM.
Amit, this works thanks.
Try :
$ awk '{print $0,$2-$1}' file
$ awk '$0 = $0 FS $2-$1' file