I can't get printf
to print a variable with the %e descriptor in a bash script. It would just say
#!/bin/bash
a=14.9
printf %e 14.9;
I know this is likely a very easy question, but I'm fairly new to bash and always used echo
. Plus I couldn't find an answer anywhere.
when run i get
$ ./test.text
./test.text: line 3: printf: 14.9: invalid number
0,000000
therefore my problem is the locale variable LC_NUMERIC: it is set so that i use commas as decimal separators. Indeed, it is set to an european localization:
$ locale | grep NUM
LC_NUMERIC="it_IT.UTF-8"
I thought I set it to en_US.UTF-8, but evidently I didn't. Now the problem switches to find how to set my locale variable. Simply using
$ LC_NUMERIC="en_US.UTF-8"
won't work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…