i'm trying to parse a file with lines like the below where i need to get a diff on the 169-182 so that the result is 13 for instance. I was looking into using bc but am not that familiar with embedding it in a script.
john8:9. 169-182
any ideas are appreciated!
joeyg
March 9, 2009, 2:07pm
2
echo "john8:9. 169-182" | cut -d" " -f2 | awk -F"-" '{print $2-$1}'
13
pludi
March 9, 2009, 2:29pm
3
echo "john8:9. 169-182" | awk '{print "(" $2 ")*-1"}' | bc
thanks joeyg and pludi. I understand your commands now so thanks. i'm trying to send a filename so would it be the following?
cut -d" " -f2 filename | awk -F"-" '{print $2-$1}'
joeyg
March 9, 2009, 3:22pm
5
In that example, your filename is an input to the rest of the command.
ok, i'm doing something more like this
awk -F" -+" '{print $3 " " $7-$6+1}' L220090213RetransRequests.log
the ibm site is goog for awk teaching:
Common threads: Awk by example, Part 1
thanks again!