I use the Italian localization of Cygwin, and therefore my printf command uses commas to separate floats, and won’t understand dot-separated floats
$ printf "%f" 3.1415
-bash: printf: 3.1415: invalid number
0,000000
$ printf "%f" 3,1415
3,141500
This gives rise to several problems because basically everything else uses a dot to separate decimal digits.
How can I change the decimal separator from comma to dot?
There are several local variables that control the localization of Cygwin (or of any bash shell, for that matter). You can see them along with their value using the
localecommand. You should see something like this:You can see the possible values of the variables by using
locale -va. They are all formatted like<language>_<nation>.UTF-8. TheUTF-8part is optional.In order to switch to "North American" float separation style, simply set
LC_NUMERICto its American value:Simply setting the variable
LC_NUMERICas if it were a regular variable won’t work. You need to use the export command.You can put this in the header of your scripts, or you can make it permanent by adding it to your
~/.bashrcor your~/.bash_profilefile.Hope this was helpful!