shortway to parse numbers with commas in bash?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    I have to go potty
    • Aug 2002
    • 55782

    #1

    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'
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


    Totally Free Templates
  • hdkiller
    Full time cybermage
    • Jun 2006
    • 461

    #2
    Code:
    i=10000; printf "%'0.0d\n" $i
    ClickPapa! - Buy and Sell traffic

    Comment

    • v0id
      Confirmed User
      • Sep 2006
      • 43

      #3
      crap you beat me to it..

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

      Comment

      Working...