Decimal separator
Colin Watson
cjwatson at ubuntu.com
Tue Dec 24 01:49:44 UTC 2013
On Mon, Dec 23, 2013 at 07:44:24PM +0100, Johnny Rosenberg wrote:
> In a terminal (bash), is there something that I can type that gives me the
> current decimal separator?
>
> For instance, if Swedish locale:
>
> $ echo "Current decimal separator: ${SomeVariable}"
> Current decimal separator: ,
> $
locale -k LC_NUMERIC
(pipe through the obvious things if you want to use this in a script
rather than just look at it)
On the other hand, if what you're really trying to do is to format a
number with thousands separators, then you want some variant of:
env printf "%'d\\n" 1000
(use a different conversion specifier such as 'g' rather than 'd' if you
need a fractional part as well; the "env" forces the use of the printf
binary from coreutils rather than any shell builtin, and in particular
dash's builtin printf is inadequate for this, although bash's builtin
printf is fine)
--
Colin Watson [cjwatson at ubuntu.com]
More information about the ubuntu-users
mailing list