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
", $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
", $1 + 0) }'
123,20
Is it possible to have gawk parsing number with ,
as decimal point without specifying
POSIX option?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…