I want gawk to parse number using comma ,
as the decimal point character.
So I set LC_NUMERIC
to fr_FR.utf-8
but it does not work:
echo 123,2 | LC_NUMERIC=fr_FR.utf-8 gawk '{printf ("%.2f\n", $1 + 0) }'
123.00
The solution is to specify option --posix
or export POSIXLY_CORRECT=1
but in this case the GNU awk extensions are not available, for example delete
or the gensub
function:
echo 123,2 | LC_NUMERIC=fr_FR.utf-8 gawk --posix '{printf ("%.2f\n", $1 + 0) }'
123,20
Is it possible to have gawk parsing number with ,
as decimal point without specifying
POSIX option?
The option your are looking for is:
Demo:
Notes:
printf
is statement not a function so the parenthesis are not required and I'm not sure why you are adding zero here?