Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 611

Format number in thousands separators with jq json cli

$
0
0

Given {"a": 1234567890}, I want 1,234,567,890 in the result, how this can be done with jq

echo '{"a": 1234567890}' | jq '.a | FORMAT?'

Thanks for @peak's answer, the solution is

echo '{"a": 1234567890}' | jq -r 'def h: [while(length>0; .[:-3]) | .[-3:]] | reverse | join(","); .a | tostring | h'//-> 1,234,567,890

Viewing all articles
Browse latest Browse all 611

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>