hi, i am trying some awk arthmatic calculation,i have a problem if any one can help
let say if i have a file
exm.txt
3 + 2
3 * 2
3 / 2
3 - 2
the output expected is
awk -f exm.awk exm.txt
3 + 2 = 5
3 * 2 = 6
3 / 2 = 1.5
3 - 2 = 1
i simply used exm.awk
{
print $1 " + " $3 "= " $1 + $3
print $1 " * " $3 "= " $1 * $3
print $1 " / " $3 "= " $1 / $3
print $1 " - " $3 "= " $1 - $3
}
it shows me the result along with other unnecessary calculation...any suggestions :o
thank you and regards...