fork(10) download
  1. #!/bin/bash
  2.  
  3. function thousands {
  4. sed -re ' :restart ; s/([0-9])([0-9]{3})($|[^0-9])/\1,\2\3/ ; t restart '
  5. }
  6. echo 12 | thousands
  7. echo 1234 | thousands
  8. echo 123456 | thousands
  9. echo 1234567 | thousands
  10. echo 123456789 | thousands
  11. echo 1234567890 | thousands
Success #stdin #stdout 0s 5076KB
stdin
Standard input is empty
stdout
12
1,234
123,456
1,234,567
123,456,789
1,234,567,890