{"id":25992556,"url":"https://github.com/cjrh/commas","last_synced_at":"2026-04-22T14:01:15.787Z","repository":{"id":272630571,"uuid":"917240320","full_name":"cjrh/commas","owner":"cjrh","description":"CLI tool to reformat text replacing whitespace with commas, or field template substitution","archived":false,"fork":false,"pushed_at":"2026-04-22T00:29:22.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-22T02:35:55.898Z","etag":null,"topics":["cli","pipeline","shell"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjrh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-15T16:09:06.000Z","updated_at":"2026-04-22T00:29:21.000Z","dependencies_parsed_at":"2025-01-16T16:07:54.247Z","dependency_job_id":null,"html_url":"https://github.com/cjrh/commas","commit_stats":null,"previous_names":["cjrh/shlex","cjrh/commas"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cjrh/commas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fcommas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fcommas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fcommas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fcommas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjrh","download_url":"https://codeload.github.com/cjrh/commas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjrh%2Fcommas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32139429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T13:27:12.868Z","status":"ssl_error","status_checked_at":"2026-04-22T13:26:44.791Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","pipeline","shell"],"created_at":"2025-03-05T14:21:19.952Z","updated_at":"2026-04-22T14:01:10.778Z","avatar_url":"https://github.com/cjrh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# commas\nTransform whitespace-separated input, either insert a delimiter or substitue a template string\nwith positional arguments.\n\n## Features\n\n- receive stdin, write stdout\n- replace whitespace with a delimiter\n- OR, substitute a template string with positional arguments\n- handles quoted fields, and writes quoted fields\n\n## Examples: Template\n\nThis is a no-nonsense field substitution tool.\n\n### Basic Test\n\n```bash\n$ echo 'a b c' | commas -t '$2 $3 $1'\nb c a\n```\n\nNote that the fields start at 1, not 0. The only reason for this is to align with\nbash so that you don't have to keep switching your mental model.\n\nQuotes work:\n\n```bash\n$ echo 'a \"b1 b2\" c' | commas -t '$2 $3 $1'\nb1 b2 c a\n```\n\nFinally, note that whitespace between the incoming values is all ignored,\nexcept of course for what is quoted, which will be preserved:\n\n```bash\n$ echo 'a     \"b1    b2\"     c' | commas -t '$2 $3 $1'\nb1    b2 c a\n```\n\nHere's a practical example. We can list the CPU cache layers:\n\n```bash\n$ lscpu | grep cache\nL1d cache:                            256 KiB (8 instances)\nL1i cache:                            256 KiB (8 instances)\nL2 cache:                             4 MiB (8 instances)\nL3 cache:                             8 MiB (2 instances)\n```\n\n`commas` can help to reformat this:\n\n```bash\n$ lscpu | grep cache | commas -t '$1 $3$4'\nL1d 256KiB\nL1i 256KiB\nL2 4MiB\nL3 8MiB\n```\n\nGoing further, there is support for trimming characters off\neach of the field values. In the above `lscpu` output, we\ncan get rid of the `:` after `cache:`, and the `(` preceding\nthe number of instances:\n\n```bash\n$ lscpu | grep cache | commas -t '$1 x $3$4 x $5' -s':('\nL1d x 256KiB x 8\nL1i x 256KiB x 8\nL2 x 4MiB x 8\nL3 x 8MiB x 2\n```\n\n## Examples: Delimiter\n\nThe delimiter mode cannot be used together with the template mode.\nThe delimiter mode is a shortcut to \"just put commas between the fields\"\nalthough the delimiter is of course configurable.\n\n### Basic Test\n\n```bash\n$ echo 'a b \"c d\" e' | commas\na,b,\"c d\",e\n```\n\nYou can choose to lose quotes in the output\n\n```bash\n$ echo 'a b \"c d\" e' | commas -l\na,b,c d,e\n```\n\n### Extra whitespace\n\nNote that `tr` does not handle this. Without `commas` you would\nhave to use `sed` or `awk`, or even something bigger like Python\nor Perl to handle this.\n\n```bash\n$ echo 'a     b    \"c d\"        e' | commas\na,b,\"c d\",e\n```\n\n\n### Pass through to `xsv`\n\nThe `xsv` tool can do a lot, but it needs comma-separated input.\nPiping data to `xsv` was the primary motivation for `commas`.\n\nHere's an example of field selection with `xsv`:\n\n```bash\n$ echo 'a     b    \"c d\"        e' | commas | xsv select 1,3\na,c d\n```\n\n### Reformat selected fields with `xsv`\n\n```bash\n$ echo 'a     b    \"c d\"        e' | commas | xsv select 1,3,4 | xsv fmt -t '|'\na|c d|e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjrh%2Fcommas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjrh%2Fcommas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjrh%2Fcommas/lists"}