awk sub work with numbers

January 29, 2010 at 04:54:16
Specs: N/A
I have a problem with numerical operations:

1:
echo 12345670 | awk '{ printf "%i\n", $1+1000}'
result:
12346670

2:
echo 12345670 | awk '{ sub($1,$1+1000); printf "%i\n", $1 }'
result
12346700

How can i get correct result in 2 version?


See More: awk sub work with numbers

Report •

#1
January 30, 2010 at 18:56:52
Hello Tmp13,

Look here:

# echo 12345 | awk '{ sub($1, $1+1000); printf "%i\n", $1}'
13345

You command works fine with lower numbers. I guess 12345670 is quite a big number for "i".

Regds


Report •
Related Solutions


Ask Question