{"id":23543211,"url":"https://github.com/inkel/bsort","last_synced_at":"2025-05-15T06:34:29.371Z","repository":{"id":136720148,"uuid":"104373404","full_name":"inkel/bsort","owner":"inkel","description":"Like sort(1) but keeping the first line as headers.","archived":false,"fork":false,"pushed_at":"2017-09-28T19:12:42.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T09:27:11.919Z","etag":null,"topics":["go","golang","sort","tool"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inkel.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}},"created_at":"2017-09-21T16:39:15.000Z","updated_at":"2017-09-29T01:33:07.000Z","dependencies_parsed_at":"2023-05-26T21:15:17.600Z","dependency_job_id":null,"html_url":"https://github.com/inkel/bsort","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkel%2Fbsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkel%2Fbsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkel%2Fbsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkel%2Fbsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inkel","download_url":"https://codeload.github.com/inkel/bsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254288325,"owners_count":22045881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["go","golang","sort","tool"],"created_at":"2024-12-26T06:19:00.676Z","updated_at":"2025-05-15T06:34:29.353Z","avatar_url":"https://github.com/inkel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `bsort` - like `sort` but keep the first line as header\nI use [`sort`](http://man7.org/linux/man-pages/man1/sort.1.html) almost daily at work, but I always hated that if I want to sort something that has a header, the header gets sorted as well. Thus, `bsort` was born.\n\nIt is a very simple program: you can only use it by piping to it and only the first line is considered as the header.\n\n## Usage\n`bsort` only works by reading from `stdin` and then sub-executing the regular `sort` on all the lines but the first one. It doesn't have any parameters of its own, so any additional parameters will be sent to `sort`.\n\nIf you want to sort one file then you can do:\n```sh\n\u003c path/to/file.txt bsort\n```\n\nIf you want to reverse sort a file by the fourth column in a numerical fashion, you can do:\n```sh\n\u003c path/to/file.txt bsort -rnk4\n```\n\nIf you want to sort many files:\n```sh\ncat path/to/file1.txt path/to/file2.txt | bsort\n```\n\nGiven that parameters are pass as they are to `sort` you could very well say _hey, I'm going to do `bsort -r file` instead of piping to it_: nothing stops you of doing that, but it will fail. You have been warned.\n\n## Installation\nIf you have a running Go environment, just do\n\n```\ngo install github.com/inkel/bsort\n```\n\nIf you prefer instead downloading precompiled binaries, you can find them in the [releases](https://github.com/inkel/bsort/releases) section. Just download the version you're looking for, place it in your `$PATH` and make it executable. Enjoy!\n\n## Example\nConsider having the following:\n\n```\n$ cat example.txt\nhost        ip          heap.percent ram.percent load node.role master name\n10.0.22.28  10.0.22.28            11          74 0.00 -         m      es-iot-master-4\n10.0.12.201 10.0.12.201           45          73 0.00 -         m      es-iot-master-3\n10.0.12.4   10.0.12.4             12          74 0.00 -         m      es-iot-master-0\n10.0.32.71  10.0.32.71            69          74 1.01 -         *      es-iot-master-2\n10.0.22.22  10.0.22.22            53          73 0.07 -         m      es-iot-master-1\n10.0.32.29  10.0.32.29            13          73 0.00 -         m      es-iot-master-5\n```\n\nIf we want to sort by `name` we can do:\n\n```\n$ \u003c example.txt bsort -k8\nhost        ip          heap.percent ram.percent load node.role master name\n10.0.12.4   10.0.12.4             12          74 0.00 -         m      es-iot-master-0\n10.0.22.22  10.0.22.22            53          73 0.07 -         m      es-iot-master-1\n10.0.32.71  10.0.32.71            69          74 1.01 -         *      es-iot-master-2\n10.0.12.201 10.0.12.201           45          73 0.00 -         m      es-iot-master-3\n10.0.22.28  10.0.22.28            11          74 0.00 -         m      es-iot-master-4\n10.0.32.29  10.0.32.29            13          73 0.00 -         m      es-iot-master-5\n```\n\nIf we wanted to do the same with the regular `sort` utility, this would be the result:\n\n```\n$ \u003c example.txt sort -k8\n10.0.12.4   10.0.12.4             12          74 0.00 -         m      es-iot-master-0\n10.0.22.22  10.0.22.22            53          73 0.07 -         m      es-iot-master-1\n10.0.32.71  10.0.32.71            69          74 1.01 -         *      es-iot-master-2\n10.0.12.201 10.0.12.201           45          73 0.00 -         m      es-iot-master-3\n10.0.22.28  10.0.22.28            11          74 0.00 -         m      es-iot-master-4\n10.0.32.29  10.0.32.29            13          73 0.00 -         m      es-iot-master-5\nhost        ip          heap.percent ram.percent load node.role master name\n```\n\nNot cool.\n\n## Why the name?\nBecause [@fsaravia](https://github.com/fsaravia) is smarter than me and he pointed out that this utility sorts the _body_ of a file.\n\n## License\nSee [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkel%2Fbsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finkel%2Fbsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkel%2Fbsort/lists"}