From 5e775c74eb35f87af0aee872e5111b918bb67ee5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 21 Jan 2025 03:45:05 +0100 Subject: [PATCH] format numbers using localized decimal and thousands separator --- l10n.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/l10n.sh b/l10n.sh index 41d3c46..9e016b0 100755 --- a/l10n.sh +++ b/l10n.sh @@ -14,3 +14,8 @@ _(){ *) printf '%s' "$*";; esac } + +num() { + { [ "$#" -gt 0 ] && printf '%s\n' "$*" || cat; } \ + | sed -E ':0 s;\.;d;; s;([0-9])([0-9]{3}[dm]);\1m\2;; t0; y;dm;,.;' +} -- 2.39.5