GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   shortway to parse numbers with commas in bash? (https://gfy.com/showthread.php?t=995558)

fris 11-02-2010 06:39 AM

shortway to parse numbers with commas in bash?
 
anyone know a shortway to parse numbers with commas in bash?

ex: 1000
becomes 1,000

and so on

this is what im using, it works, but wondering if theirs anything shorter

Code:

echo 10000 | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'

hdkiller 11-02-2010 06:53 AM

Code:

i=10000; printf "%'0.0d\n" $i

v0id 11-02-2010 06:56 AM

crap you beat me to it.. :thumbsup

Code:

echo 1000 | xargs printf "%'0.0d\n"


All times are GMT -7. The time now is 09:00 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123