{"id":13436134,"url":"https://github.com/theryangeary/choose","last_synced_at":"2025-05-14T11:08:57.420Z","repository":{"id":40599825,"uuid":"207951619","full_name":"theryangeary/choose","owner":"theryangeary","description":"A human-friendly and fast alternative to cut (and sometimes awk)","archived":false,"fork":false,"pushed_at":"2024-10-01T22:13:06.000Z","size":130,"stargazers_count":1967,"open_issues_count":11,"forks_count":46,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-10T02:47:33.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theryangeary.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","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":"2019-09-12T02:54:01.000Z","updated_at":"2025-05-07T03:58:28.000Z","dependencies_parsed_at":"2024-06-19T00:16:23.794Z","dependency_job_id":"f1d13857-cfda-4401-a8e8-bdaf25df6ecb","html_url":"https://github.com/theryangeary/choose","commit_stats":{"total_commits":123,"total_committers":7,"mean_commits":"17.571428571428573","dds":0.05691056910569103,"last_synced_commit":"c6cb007f2b854ba6ca4c65657c2052866f026f32"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theryangeary%2Fchoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theryangeary%2Fchoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theryangeary%2Fchoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theryangeary%2Fchoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theryangeary","download_url":"https://codeload.github.com/theryangeary/choose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129484,"owners_count":22019628,"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":[],"created_at":"2024-07-31T03:00:44.536Z","updated_at":"2025-05-14T11:08:57.392Z","avatar_url":"https://github.com/theryangeary.png","language":"Rust","funding_links":[],"categories":["HarmonyOS","Command Line","Rust","CLI","awk, sed, tr, and cut","Applications","Tools","\u003ca name=\"text-processing\"\u003e\u003c/a\u003eText processing","Text Processing","Tool","Other"],"sub_categories":["Windows Manager","Dependency Management","System tools","Rust","TUI Tool"],"readme":"# Choose\n\nThis is `choose`, a human-friendly and fast alternative to `cut` and (sometimes) `awk`\n\n[![`choose` demo](https://asciinema.org/a/315932.png)](https://asciinema.org/a/315932?autoplay=1)\n\n## Features\n\n- terse field selection syntax similar to Python's list slices\n- negative indexing from end of line\n- optional start/end index\n- zero-indexed\n- reverse ranges\n- slightly faster than `cut` for sufficiently long inputs, much faster than\n  `awk`\n- regular expression field separators using Rust's regex syntax\n\n## Rationale\n\nThe AWK programming language is designed for text processing and is extremely\ncapable in this endeavor. However, the `awk` command is not ideal for rapid\nshell use, with its requisite quoting of a line wrapped in curly braces, even\nfor the simplest of programs:\n\n```bash\nawk '{print $1}'\n```\n\nLikewise, `cut` is far from ideal for rapid shell use, because of its confusing\nsyntax. Field separators and ranges are just plain difficult to get right on the\nfirst try.\n\nIt is for these reasons that I present to you `choose`. It is not meant to be a\ndrop-in or complete replacement for either of the aforementioned tools, but\nrather a simple and intuitive tool to reach for when the basics of `awk` or\n`cut` will do, but the overhead of getting them to behave should not be\nnecessary.\n\n## Contributing\n\nPlease see our guidelines in [contributing.md](contributing.md).\n\n## Usage\n\n```\n$ choose --help\nchoose 1.2.0\n`choose` sections from each line of files\n\nUSAGE:\n    choose [FLAGS] [OPTIONS] \u003cchoices\u003e...\n\nFLAGS:\n    -c, --character-wise    Choose fields by character number\n    -d, --debug             Activate debug mode\n    -x, --exclusive         Use exclusive ranges, similar to array indexing in many programming languages\n    -h, --help              Prints help information\n    -n, --non-greedy        Use non-greedy field separators\n    -V, --version           Prints version information\n\nOPTIONS:\n    -f, --field-separator \u003cfield-separator\u003e\n            Specify field separator other than whitespace, using Rust `regex` syntax\n\n    -i, --input \u003cinput\u003e                                      Input file\n    -o, --output-field-separator \u003coutput-field-separator\u003e    Specify output field separator\n\nARGS:\n    \u003cchoices\u003e...    Fields to print. Either a, a:b, a..b, or a..=b, where a and b are integers. The beginning or end\n                    of a range can be omitted, resulting in including the beginning or end of the line,\n                    respectively. a:b is inclusive of b (unless overridden by -x). a..b is exclusive of b and a..=b\n                    is inclusive of b\n```\n\n### Examples\n\n```bash\nchoose 5                # print the 5th item from a line (zero indexed)\n\nchoose -f ':' 0 3 5     # print the 0th, 3rd, and 5th item from a line, where\n                        # items are separated by ':' instead of whitespace\n\nchoose 2:5              # print everything from the 2nd to 5th item on the line,\n                        # inclusive of the 5th\n\nchoose -x 2:5           # print everything from the 2nd to 5th item on the line,\n                        # exclusive of the 5th\n\nchoose :3               # print the beginning of the line to the 3rd item\n\nchoose -x :3            # print the beginning of the line to the 3rd item,\n                        # exclusive\n\nchoose 3:               # print the third item to the end of the line\n\nchoose -1               # print the last item from a line\n\nchoose -3:-1            # print the last three items from a line\n```\n\n## Compilation and Installation\n\n### Installing From Source\n\nIn order to build `choose` you will need the rust toolchain installed. You can\nfind instructions [here](https://www.rust-lang.org/tools/install).\n\nThen, to install:\n\n```bash\ngit clone https://github.com/theryangeary/choose.git\ncd choose\ncargo build --release\ninstall target/release/choose \u003cDESTDIR\u003e\n```\n\nJust make sure DESTDIR is in your path.\n\n### Installing From Package Managers\n\nCargo:\n\n```sh\ncargo install choose\n```\n\nArch Linux:\n\n```sh\nyay -S choose-rust-git\n```\n\nFedora/CentOS [COPR](https://copr.fedorainfracloud.org/coprs/atim/choose/):\n\n```sh\ndnf copr enable atim/choose\ndnf install choose\n```\n\nHomebrew:\n\n```sh\nbrew install choose-rust\n```\n\nMacPorts:\n\n```sh\nsudo port install choose\n```\n\n### Benchmarking\n\nBenchmarking is performed using the [`bench` utility](https://github.com/Gabriel439/bench).\n\nBenchmarking is based on the assumption that there are five files in `test/`\nthat match the glob \"long*txt\". GitHub doesn't support files big enough in\nnormal repos, but for reference the files I'm working with have lengths like\nthese:\n\n```sh\n     1000 test/long.txt\n    19272 test/long_long.txt\n    96360 test/long_long_long.txt\n   963600 test/long_long_long_long.txt\n 10599600 test/long_long_long_long_long.txt\n```\n\nand content generally like this:\n\n```\nThose an equal point no years do. Depend warmth fat but her but played. Shy and\nsubjects wondered trifling pleasant. Prudent cordial comfort do no on colonel as\nassured chicken. Smart mrs day which begin. Snug do sold mr it if such.\nTerminated uncommonly at at estimating. Man behaviour met moonlight extremity\nacuteness direction.\n\nIgnorant branched humanity led now marianne too strongly entrance. Rose to shew\nbore no ye of paid rent form. Old design are dinner better nearer silent excuse.\nShe which are maids boy sense her shade. Considered reasonable we affronting on\nexpression in. So cordial anxious mr delight. Shot his has must wish from sell\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheryangeary%2Fchoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheryangeary%2Fchoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheryangeary%2Fchoose/lists"}