{"id":42269134,"url":"https://github.com/alecthomas/t","last_synced_at":"2026-02-01T13:00:48.697Z","repository":{"id":334681003,"uuid":"1142293888","full_name":"alecthomas/t","owner":"alecthomas","description":"`t` is a concise language for manipulating text, replacing common usage patterns of Unix utilities like grep, sed, cut, awk, sort, and uniq.","archived":false,"fork":false,"pushed_at":"2026-01-31T19:29:13.000Z","size":248,"stargazers_count":227,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-31T21:51:38.016Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-01-26T08:06:43.000Z","updated_at":"2026-01-31T19:29:17.000Z","dependencies_parsed_at":"2026-01-31T11:00:47.065Z","dependency_job_id":null,"html_url":"https://github.com/alecthomas/t","commit_stats":null,"previous_names":["alecthomas/t"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/alecthomas/t","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/t/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Ft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28978716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T12:13:08.691Z","status":"ssl_error","status_checked_at":"2026-02-01T12:13:08.356Z","response_time":56,"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":[],"created_at":"2026-01-27T07:10:55.292Z","updated_at":"2026-02-01T13:00:48.678Z","avatar_url":"https://github.com/alecthomas.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# T - a text processing language and utility\n\n`t` is a concise language for manipulating text, replacing common usage patterns of Unix utilities like grep, sed, cut, awk, sort, and uniq.\n\n\n![Histogram](histogram.svg)\n\n\n## Usage\n\n```\nt [\u003cflags\u003e] \u003cprogramme\u003e [\u003cfile\u003e ...]\n```\n\n## Example - top 20 most frequent words, lowercased\n\nUsing traditional Unix utilities:\n\n```bash\ntr -s '[:space:]' '\\n' \u003c file | tr A-Z a-z | sort | uniq -c | sort -rn | head -20\n```\n\nThe equivalent in `t` would be:\n\n```bash\nt 'sfld:20' file\n```\n\nGoing through the programme step by step gives us:\n\n| Op | State | Description |\n|----|-------|-------------|\n| | `[line, line, ...]` | lines of input |\n| `s` | `[[word, word], [word], ...]` | split each line into words |\n| `f` | `[word, word, word, ...]` | flatten into single list |\n| `l` | `[word, word, word, ...]` | lowercase each word |\n| `d` | `[[5, \"the\"], [3, \"cat\"], ...]` | dedupe with counts |\n| `:20` | `[[5, \"the\"], [3, \"cat\"], ...]` | take first 20 |\n\n## Installation\n\n```sh\ncurl -fsSL https://raw.githubusercontent.com/alecthomas/t/master/install.sh | sh\n```\n\nTo install a specific version or to a custom directory:\n\n```sh\ncurl -fsSL https://raw.githubusercontent.com/alecthomas/t/master/install.sh | sh -s v0.0.1\ncurl -fsSL https://raw.githubusercontent.com/alecthomas/t/master/install.sh | INSTALL_DIR=~/.local/bin sh\n```\n\n## Data Model\n\nBy default, input is a flat stream of lines, with each input file's lines concatenated together: `[line, line, ...]`.\n\nMost operators apply to each element of the current array individually. For example, `l` (lowercase) on `[\"Hello\", \"World\"]` produces `[\"hello\", \"world\"]`—each element is lowercased independently.\n\nOperators come in three kinds:\n\n- **Transform** (map): apply to each element. `l` on `[\"Hello\", \"World\"]` → `[\"hello\", \"world\"]`\n- **Filter**: keep or remove elements. `/x/` on `[\"ax\", \"\", \"cx\"]` → `[\"ax\", \"cx\"]`\n- **Reduce**: collapse array to a value. `#` on `[\"a\", \"b\", \"c\"]` → `3`\n\nElement-wise transforms (`u`, `l`, `t`, `n`, `r`, `+`) recurse through nested arrays automatically. Structural operators (`d`, `#`, `o`, `O`, selection) operate on the top-level array only—use `@` to apply them at deeper levels.\n\nSelection (`0`, `:3`, `0,2:5,8`) is a reduce operator—it collapses the array to a subset. To apply selection within each element of a nested structure, use `@` to descend first.\n\nUse `@` to descend into nested structures, `^` to ascend back up. \n\n## Type System\n\nThere are three types:\n\n| Type | Description |\n|------|-------------|\n| array | ordered collection of values |\n| string | text |\n| number | numeric value (converted from string via `n`) |\n\nInput is always an array of strings (lines). Operators like `s` create nested arrays, `j` joins them back. Numbers only exist after explicit conversion with `n`, and are used by numeric operators like `+`.\n\n## Split/Join Semantics\n\n`s` and `j` are inverse operations—`sj` always returns the original value.\n\nArrays have a semantic \"level\" that determines how `s` splits and `j` joins:\n\n| Array Level | `s` splits text into | `j` joins with |\n|-------------|----------------------|----------------|\n| file | lines | newline |\n| line | words | space |\n| word | chars | nothing |\n\n`s` operates only on the direct text elements of an array—it does not recurse into nested arrays. To split at deeper levels, use `@` to descend first.\n\n`j` joins the elements of each nested array back into text, reversing the effect of `s`. It does not flatten—use `@` to join at deeper levels.\n\n## Operators\n\n### Quick Reference\n\n#### Structural\n\n| Operator | Meaning |\n|----------|---------|\n| `s` | split natural |\n| `S\u003cchar\u003e` or `S\"\u003cdelim\u003e\"` | split on delimiter |\n| `j` | join natural (inverse of `s`) |\n| `J\u003cchar\u003e` or `J\"\u003cdelim\u003e\"` | join with delimiter |\n| `f` | flatten one level |\n\n#### Transform\n\n| Operator | Meaning |\n|----------|---------|\n| `l` | lowercase |\n| `L\u003cselection\u003e` | lowercase selected |\n| `u` | uppercase |\n| `U\u003cselection\u003e` | uppercase selected |\n| `r[\u003cselection\u003e]/\u003cold\u003e/\u003cnew\u003e/` | replace (regex), optionally in selected |\n| `n` | to number |\n| `N\u003cselection\u003e` | to number selected |\n| `t` | trim whitespace |\n| `T\u003cselection\u003e` | trim selected |\n\n#### Filter\n\n| Operator | Meaning |\n|----------|---------|\n| `/\u003cregex\u003e/` | keep matching |\n| `!/\u003cregex\u003e/` | keep non-matching |\n| `x` | delete empty |\n\n#### Reduce\n\n| Operator | Meaning |\n|----------|---------|\n| `\u003cselection\u003e` | select elements (index, slice, or multi) |\n| `o` | sort descending |\n| `O` | sort ascending |\n| `g\u003cselection\u003e` | group by |\n| `d` | dedupe with counts |\n| `D\u003cselection\u003e` | dedupe by selected field |\n| `#` | count |\n| `+` | sum |\n| `c` | columnate |\n| `p\u003cselection\u003e` | partition at indices |\n\n#### Navigation\n\n| Operator | Meaning |\n|----------|---------|\n| `@` | descend |\n| `^` | ascend |\n\n#### Misc\n\n| Operator | Meaning |\n|----------|---------|\n| `;` | separator (no-op) |\n\n### Operator Details\n\n#### `s` - Split\n\nSplits text elements of the current array according to the array's semantic level:\n\n- **file** array → splits text into lines (on newlines)\n- **line** array → splits text into words (on whitespace)\n- **word** array → splits text into characters\n\nArray elements are left unchanged—`s` does not recurse. Use `@` to descend and split at deeper levels.\n\n```\n# Split lines into words (line array)\n[\"hello world\", \"foo bar\"]  →  [[\"hello\", \"world\"], [\"foo\", \"bar\"]]\n\n# Split words into chars (word array, after sj)\n[\"hello\", \"world\"]  →  [[\"h\",\"e\",\"l\",\"l\",\"o\"], [\"w\",\"o\",\"r\",\"l\",\"d\"]]\n```\n\n#### `S\u003cdelim\u003e` - Split on Delimiter\n\nSplits on a custom delimiter. Use a single character directly, or quotes for multi-character delimiters:\n\n- `S,` splits on comma\n- `S:` splits on colon\n- `S\"::\"` splits on `::`\n\n```\n# Split CSV\n\"a,b,c\"  →  [\"a\", \"b\", \"c\"]   (with S,)\n\n# Split on ::\n\"a::b::c\"  →  [\"a\", \"b\", \"c\"]   (with S\"::\")\n```\n\n#### `j` - Join\n\nThe inverse of `s`—joins nested arrays back into text using the appropriate delimiter for the array level. `sj` always returns the original value.\n\n```\n# Join words back into lines (after s)\n[[\"hello\", \"world\"], [\"foo\", \"bar\"]]  →  [\"hello world\", \"foo bar\"]\n\n# Join chars back into words (after s@s)\n[[\"h\",\"e\",\"l\",\"l\",\"o\"], [\"w\",\"o\",\"r\",\"l\",\"d\"]]  →  [\"hello\", \"world\"]\n```\n\n#### `J\u003cdelim\u003e` - Join with Delimiter\n\nJoins array elements with a custom delimiter:\n\n- `J,` joins with comma\n- `J\"\\n\"` joins with newline\n\n```\n[\"a\", \"b\", \"c\"]  →  \"a,b,c\"   (with J,)\n```\n\n#### `f` - Flatten\n\nFlattens nested arrays by one level. Non-array elements are kept as-is.\n\n```\n[[\"a\", \"b\"], [\"c\"]]  →  [\"a\", \"b\", \"c\"]\n[[\"a\", [\"b\", \"c\"]], [\"d\"]]  →  [\"a\", [\"b\", \"c\"], \"d\"]   (only one level)\n```\n\n#### `l` - Lowercase\n\nConverts all text to lowercase. Works recursively on arrays.\n\n```\n[\"Hello\", \"WORLD\"]  →  [\"hello\", \"world\"]\n```\n\n#### `L\u003cselection\u003e` - Lowercase Selected\n\nLowercases only the elements at the specified indices:\n\n```\n[\"HELLO\", \"WORLD\", \"FOO\"]  →  [\"hello\", \"WORLD\", \"FOO\"]   (with L0)\n[\"HELLO\", \"WORLD\", \"FOO\"]  →  [\"hello\", \"world\", \"FOO\"]   (with L:2)\n```\n\n#### `u` - Uppercase\n\nConverts all text to uppercase. Works recursively on arrays.\n\n```\n[\"Hello\", \"world\"]  →  [\"HELLO\", \"WORLD\"]\n```\n\n#### `U\u003cselection\u003e` - Uppercase Selected\n\nUppercases only the elements at the specified indices.\n\n#### `r[\u003cselection\u003e]/\u003cold\u003e/\u003cnew\u003e/` - Replace (Regex)\n\nReplaces matches of regex `\u003cold\u003e` with `\u003cnew\u003e`. Recurses through nested arrays.\n\nWith an optional selection, applies replacement only to elements at the specified indices.\n\n```\n# Remove prefix\n[\"ERROR: fail\", \"ERROR: crash\"]  →  [\"fail\", \"crash\"]   (with r/ERROR: //)\n\n# Replace pattern\n[\"cat\", \"hat\"]  →  [\"dog\", \"hat\"]   (with r/cat/dog/)\n\n# Replace only in first element\n[\"cat\", \"cat\"]  →  [\"dog\", \"cat\"]   (with r0/cat/dog/)\n```\n\n#### `n` - To Number\n\nConverts strings to numbers. Recurses through nested arrays. Non-numeric strings error.\n\n```\n[\"42\", \"3.14\", \"100\"]  →  [42, 3.14, 100]\n```\n\n#### `N\u003cselection\u003e` - To Number Selected\n\nConverts only the elements at the specified indices to numbers.\n\n#### `t` - Trim\n\nRemoves leading and trailing whitespace from each string. Recurses through nested arrays.\n\n```\n[\"  hello  \", \"\\tworld\\n\"]  →  [\"hello\", \"world\"]\n```\n\n#### `T\u003cselection\u003e` - Trim Selected\n\nTrims only the elements at the specified indices.\n\n#### `/\u003cregex\u003e/` - Filter Keep\n\nKeeps only elements matching the regex.\n\n```\n[\"apple\", \"banana\", \"apricot\"]  →  [\"apple\", \"apricot\"]   (with /^a/)\n```\n\n#### `!/\u003cregex\u003e/` - Filter Remove\n\nRemoves elements matching the regex (keeps non-matching).\n\n```\n[\"apple\", \"banana\", \"apricot\"]  →  [\"banana\"]   (with !/^a/)\n```\n\n#### `x` - Delete Empty\n\nRemoves empty strings and empty arrays from the current array.\n\n```\n[\"hello\", \"\", \"world\", \"\"]  →  [\"hello\", \"world\"]\n```\n\n#### `\u003cselection\u003e` - Select\n\nSelects elements by index, slice, or combination. See [Selection](#selection) for full syntax.\n\n- Single index returns the element itself\n- Multiple indices or slices return an array\n\nAlso works on strings, treating them as character arrays:\n\n```\n\"hello\"  →  \"h\"       (with 0)\n\"hello\"  →  \"olleh\"   (with ::-1)\n```\n\n#### `o` - Sort Descending\n\nSorts the array in descending order. For arrays of arrays, sorts lexicographically (first element, then second, etc.).\n\n```\n[3, 1, 4, 1, 5]  →  [5, 4, 3, 1, 1]\n[[2, \"b\"], [1, \"a\"], [2, \"a\"]]  →  [[2, \"b\"], [2, \"a\"], [1, \"a\"]]\n```\n\n#### `O` - Sort Ascending\n\nSorts the array in ascending order.\n\n```\n[3, 1, 4, 1, 5]  →  [1, 1, 3, 4, 5]\n```\n\n#### `g\u003cselection\u003e` - Group By\n\nGroups elements by the value(s) at the specified selection. Produces `[[key, [elements...]], ...]`.\n\n```\n# Group by first element\n[[\"a\", 1], [\"b\", 2], [\"a\", 3]]  →  [[\"a\", [[\"a\", 1], [\"a\", 3]]], [\"b\", [[\"b\", 2]]]]   (with g0)\n\n# Group by slice (composite key)\ng0:2  →  key is [first, second] elements\n```\n\n#### `d` - Dedupe with Counts\n\nRemoves duplicates and counts occurrences. Returns `[[count, value], ...]` sorted by count descending.\n\n```\n[\"a\", \"b\", \"a\", \"a\", \"b\"]  →  [[3, \"a\"], [2, \"b\"]]\n```\n\n#### `D\u003cselection\u003e` - Dedupe by Field\n\nRemoves duplicates based on the value at the specified selection, counting occurrences. Returns `[[count, element], ...]` sorted by count descending.\n\n```\n# Dedupe by first element\n[[\"a\", 1], [\"b\", 2], [\"a\", 3]]  →  [[2, [\"a\", 1]], [1, [\"b\", 2]]]   (with D0)\n```\n\n#### `#` - Count\n\nReturns the number of elements in the array.\n\n```\n[\"a\", \"b\", \"c\"]  →  3\n```\n\n#### `+` - Sum\n\nSums all numeric values. Recurses through nested arrays. Strings are coerced to numbers (non-numeric strings contribute 0).\n\n```\n[1, 2, 3, 4]  →  10\n[[\"1\", \"2\"], [\"3\", \"4\"]]  →  10\n```\n\n#### `c` - Columnate\n\nFormats array of arrays as aligned columns (like `column -t`). Each column width is automatically determined by the widest element in that column.\n\n```\n[[\"name\", \"age\"], [\"alice\", \"30\"], [\"bob\", \"25\"]]\n→\nname   age\nalice  30\nbob    25\n```\n\n#### `p\u003cselection\u003e` - Partition\n\nSplits an array or string at the specified indices. Each index becomes a split point.\n\n```\n# Split at index 2\n[\"a\", \"b\", \"c\", \"d\", \"e\"]  →  [[\"a\", \"b\"], [\"c\", \"d\", \"e\"]]   (with p2)\n\n# Split at multiple indices\n[\"a\", \"b\", \"c\", \"d\", \"e\"]  →  [[\"a\"], [\"b\", \"c\"], [\"d\", \"e\"]]   (with p1,3)\n\n# Chunk into groups of 2 (split at every 2nd index)\n[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]  →  [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"]]   (with p::2)\n```\n\nAlso works on strings:\n\n```\n\"hello\"  →  [\"he\", \"llo\"]   (with p2)\n\"abcdef\"  →  [\"ab\", \"cd\", \"ef\"]   (with p::2)\n```\n\n#### `@` - Descend\n\nDescends one level into the data structure. Subsequent operations apply to each element of the current array, rather than the array itself.\n\n```\n# Without @: select first element of outer array\n[[\"a\", \"b\"], [\"c\", \"d\"]]  →  [\"a\", \"b\"]   (with 0)\n\n# With @: select first element of EACH inner array\n[[\"a\", \"b\"], [\"c\", \"d\"]]  →  [\"a\", \"c\"]   (with @0)\n```\n\nMultiple `@` descends multiple levels:\n\n```\n# @@0 operates on elements of elements of elements\n```\n\n#### `^` - Ascend\n\nAscends one level, undoing a previous `@`. Returns focus to the parent array.\n\n```\n# Split, descend, select first word, ascend\n\"hello world\\nfoo bar\"  →  [\"hello\", \"foo\"]   (with s@0)\n```\n\n#### `;` - Separator\n\nA no-op operator that does nothing. Useful for visually separating groups of operators in complex programmes.\n\n```\n# Without separator\ns@0^do:10\n\n# With separator for readability\ns@0^;d;o;:10\n```\n\n## Selection\n\nSelection is a reduce operator—it collapses the array to a subset. Selecting a single element returns that element; selecting multiple returns an array:\n\n| Syntax | Meaning | Result |\n|--------|---------|--------|\n| `\u003cn\u003e` | single index (0-based) | element |\n| `-\u003cn\u003e` | negative index (from end) | element |\n| `\u003cn\u003e:\u003cm\u003e` | slice (exclusive end) | array |\n| `\u003cn\u003e:` | slice to end | array |\n| `:\u003cm\u003e` | slice from start | array |\n| `\u003cn\u003e:\u003cm\u003e:\u003cs\u003e` | slice with stride | array |\n| `\u003cn\u003e,\u003cm\u003e,\u003cp\u003e` | select multiple | array |\n| `\u003cn\u003e,\u003cm\u003e:\u003cp\u003e` | mixed index + slice | array |\n\nTo apply selection within each element of a nested structure, use `@` to descend first:\n\n```bash\n# Select first 3 lines\nt ':3' file\n\n# Split lines into words, then select first word of each line\nt 's@0' file\n\n# Split on colon, select first and last fields of each line\nt 'S:@0,-1' /etc/passwd\n\n# Split into words, select 1st, 3rd, 4th of each line\nt 's@0,2,3' file\n\n# Reorder columns: last column first, then rest\nt 's@-1,0:-1' file\n```\n\n## Grouping\n\n`g\u003cselection\u003e` groups elements by the value(s) at the specified selection, producing `[[key, [element, ...]], ...]`.\n\n| Syntax | Meaning |\n|--------|---------|\n| `g0` | group by first element |\n| `g-1` | group by last element |\n| `g1,2` | group by composite key (elements 1 and 2) |\n| `g0:3` | group by first three elements as key |\n\nExamples:\n\n```bash\n# Group log lines by IP (first field)\nt 'sg0' access.log\n# → [[\"192.168.1.1\", [[192.168.1.1, -, -, ...], ...]], [\"10.0.0.5\", [...]], ...]\n\n# Group CSV rows by region (field 2)\nt 'S,g2' sales.csv\n\n# Group by composite key: method + status code\nt 'sg0,8' access.log\n\n# Group by IP (first field), showing all requests per IP\nt 'sg0' access.log\n# → [[\"192.168.1.1\", [[...], [...]]], [\"10.0.0.5\", [[...]]]]\n\n# Group by IP, show top 10 offenders with their actual requests\nt 'sg0o:10' access.log\n```\n\n## Aggregation \u0026 Cleaning\n\n| Operator | Behavior | Example |\n|----------|----------|---------|\n| `#` | count: `[a, b, c]` → `3` | `t '#' file` (line count) |\n| `+` | sum: `[1, 2, 3]` → `6` | `t 'S,@1n+' data.csv` (sum column 2) |\n| `t` | trim whitespace (per element) | `t 't' file` (trim each line) |\n| `x` | delete empty elements | `t 'x' file` (remove blank lines) |\n\n## Interactive Mode\n\nInteractive mode allows a user to live preview programmes as they're typed.\nPressing `^J` will toggle between text and JSON modes.\n\n```bash\n$ t -i access.log\nLoaded 124847 lines\nt\u003e s                     # live preview as you type\n[[192.168.1.1, -, -, ...], [10.0.0.5, -, -, ...], ...]\nt\u003e s@8\n[\"200\", \"404\", \"200\", \"500\", ...]\nt\u003e s@8^d\n[[98423, \"200\"], [1042, \"404\"], [89, \"500\"], ...]\nt\u003e s@8^do\n[[98423, \"200\"], [1042, \"404\"], [89, \"500\"], ...]\nt\u003e s@8^do:10\u003cEnter\u003e      # enter commits\n```\n\n## CLI Flags\n\n| Flag | Meaning |\n|------|---------|\n| `-d \u003cdelim\u003e` | input delimiter (what `s` splits on) |\n| `-D \u003cdelim\u003e` | output delimiter (what `j` joins with) |\n| `-c` | CSV mode (split/join handle quoted fields) |\n| `-e \u003cprog\u003e` | explain |\n| `-p \u003cprog\u003e` | parse tree |\n| `-i` | interactive |\n| `-j` | json output |\n\n## Rosetta Stone\n\n### Filtering\n\n**Lines with \"fail\" but not \"expected\":**\n```bash\ngrep fail file | grep -v expected\nt '/fail/!/expected/' file\n```\n\n**Error messages, deduped and sorted by frequency:**\n```bash\ngrep ERROR app.log | sed 's/.*ERROR: //' | sort | uniq -c | sort -rn\nt '/ERROR/r/.*ERROR: //do' app.log\n```\n\n### Field Selection\n\n**Select specific columns (1st, 3rd, 4th) from whitespace-delimited file:**\n```bash\nawk '{print $1, $3, $4}' file\nt 's@0,2,3' file\n```\n\n**Extract username and shell from /etc/passwd:**\n```bash\nawk -F: '{print $1, $7}' /etc/passwd\nt 'S:@0,-1' /etc/passwd\n```\n\n**Reorder CSV columns (swap first two, keep rest):**\n```bash\nawk -F, -v OFS=, '{print $2, $1, $3}' file\nt 'S,@1,0,2:J,' file\n```\n\n**Colon-delimited: 5th field, lowercased, reversed:**\n```bash\ncut -d: -f5 /etc/passwd | tr A-Z a-z | rev\nt 'S:@4ls::-1j' /etc/passwd\n```\n\n### Grouping\n\n**Group log lines by IP, see all requests from each:**\n```bash\n# No simple Unix equivalent - requires awk with arrays\nawk '{a[$1] = a[$1] ? a[$1] \"\\n\" $0 : $0} END {for (k in a) print \"==\" k \"==\\n\" a[k]}' access.log\nt 'sg0' access.log\n```\n\n**Group errors by error type, show all occurrences:**\n```bash\n# Complex in traditional tools\nt '/ERROR/r/.*ERROR: //sg0' app.log\n```\n\n**Group by field:**\n```bash\n# No simple Unix equivalent - requires awk with arrays\nt 'sg0' access.log\n```\n\n**Group CSV by category (column 3), extract values (column 2):**\n```bash\nawk -F, '{a[$3] = a[$3] \" \" $2} END {for (k in a) print k, a[k]}' data.csv\nt 'S,g2@1@1' data.csv\n```\n\n### Frequency \u0026 Deduplication\n\n**Request counts by IP (first field of log):**\n```bash\nawk '{print $1}' access.log | sort | uniq -c | sort -rn\nt 's@0^do' access.log\n```\n\n**HTTP status code distribution (9th field):**\n```bash\nawk '{print $9}' access.log | sort | uniq -c | sort -rn\nt 's@8^do' access.log\n```\n\n**Most requested URLs (7th field), top 20:**\n```bash\nawk '{print $7}' access.log | sort | uniq -c | sort -rn | head -20\nt 's@6^do:20' access.log\n```\n\n**Top 10 file extensions:**\n```bash\nls -1 | grep '\\.' | rev | cut -d. -f1 | rev | sort | uniq -c | sort -rn | head -10\nt '/\\./S.@-1^do:10' filelist\n```\n\n**CSV: value frequency in column 1:**\n```bash\ncut -d, -f1 data.csv | sort | uniq -c | sort -rn\nt 'S,@0^do' data.csv\n```\n\n**CSV: unique values in column 3, sorted:**\n```bash\ncut -d, -f3 data.csv | sort -u\nt 'S,@2^DO' data.csv\n```\n\n**Extract and count email domains:**\n```bash\ngrep -E '@' file | sed 's/.*@//' | sed 's/[^a-zA-Z0-9.-].*//' | sort | uniq -c | sort -rn\nt '/@/S@@-1^do' file\n```\n\n**Remove duplicate words within each line:**\n```bash\nawk '{delete a; for(i=1;i\u003c=NF;i++) if(!a[$i]++) printf \"%s \", $i; print \"\"}' file\nt 's@D0@1^J\" \"' file\n```\n\n### Counting \u0026 Aggregation\n\n**Count lines (like wc -l):**\n```bash\nwc -l \u003c file\nt '#' file\n```\n\n**Count words (like wc -w):**\n```bash\nwc -w \u003c file\nt 'sf#' file\n```\n\n**Sum a column of numbers:**\n```bash\nawk '{sum+=$1} END{print sum}' file\nt 'n+' file\n```\n\n**Sum column 2 of a CSV:**\n```bash\nawk -F, '{sum+=$2} END{print sum}' data.csv\nt 'S,@1n+' data.csv\n```\n\n### Cleaning \u0026 Transformation\n\n**Remove blank lines:**\n```bash\nsed '/^$/d' file\nt 'x' file\n```\n\n**Trim whitespace from each line:**\n```bash\nsed 's/^[ \\t]*//;s/[ \\t]*$//' file\nt 't' file\n```\n\n**Reverse words within each line:**\n```bash\nawk '{for(i=NF;i\u003e=1;i--) printf \"%s \", $i; print \"\"}' file\nt 's@::-1j' file\n```\n\n**Reverse each word's characters (hello world → olleh dlrow):**\n```bash\n# Bash equivalent is ugly:\nwhile IFS= read -r line; do echo \"$line\" | xargs -n1 | rev | xargs; done \u003c file\nt 's@s@::-1^j^j' file\n```\n\n### Slicing\n\n**Every 3rd line, starting from line 2:**\n```bash\nawk 'NR%3==2' file\nt '1::3' file\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Ft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecthomas%2Ft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Ft/lists"}