Gå til hovedinnhold

CLI tools

kgrep, ksed and kcat are format-aware reimaginings of the classic Unix text utilities. Where grep, sed and cat operate on raw bytes — lines of a file as the operating system stores them — these operate on the translatable text that kapi extracts from a document, regardless of how that text is encoded on disk.

The practical consequence: you can search the prose inside a Word .docx, rewrite a phrase across a directory of JSON catalogs, or print the segments of an XLIFF file as plain text — using muscle memory from tools you already know, without first converting anything.

A fourth utility, kconv, has no classic Unix analog: it converts between formats — a .docx to clean Markdown, a DocLang document to HTML, or any supported format to DocLang — carrying the document's structure across rather than its bytes.

The video below shows the whole loop on a sales team's collateral — a Markdown pitch, a Word proposal, and an Excel price list. kcat prints the text inside each file, kgrep finds the product name across all three at once, and a single ksed rebrands it everywhere — rewriting each document back into its own format.

Each works on every one of the 50+ file formats neokapi reads — Office documents, localization and data formats, markup, and more. See the Format Reference for the full list.

Why blocks, not lines

A .docx has no "lines" in the byte sense; a JSON catalog's meaningful units are keyed strings, not file rows. kapi parses a document into blocks of translatable content and strips the surrounding markup and structure. The toolbox operates on those blocks:

  • kcat prints one block per output line.
  • kgrep reports one matching block per line, and -n prefixes the block's ordinal position. For genuinely line-oriented formats such as plain text, one block is one line, so -n reads exactly like grep -n.
  • ksed rewrites a block's text and asks the format writer to reconstruct the document, so structure is preserved.
  • kconv hands the blocks — and the role each one carries (heading, list item, table cell) — to a different format's writer, projecting the document's structure into the target format.

Installation

The Kapi CLI bundles these commands:

brew install neokapi/tap/kapi-cli # macOS/Linux
winget install Neokapi.Kapi # Windows

Every utility is also reachable as a kapi subcommand — kapi grep, kapi sed, kapi cat, kapi convert — which behaves identically to the matching short name on every platform.

Windows

The Homebrew install adds the short names (kgrep, ksed, kcat, kconv) as aliases of the kapi binary. The winget package installs the single kapi command, so on Windows use the subcommand form — kapi grep, kapi sed, kapi cat, kapi convert — which is exactly equivalent.

Conventions shared across the toolbox

  • Standard input. With no file argument, or when the file is -, input is read from standard input. Without a file extension to go by, the format is sniffed from the content and falls back to plain text.
  • Format selection. -f, --format overrides format detection (for example -f json). Note this differs from grep/sed, where -f reads patterns or scripts from a file; in the toolbox -f always means format, matching the rest of the kapi CLI. Use -e for explicit patterns and scripts.
  • Source vs. translation. For multilingual formats the utilities by default operate on the source text. --target LOCALE operates on a target language instead — for example kgrep --target fr "déconnexion" messages.xliff searches the French translations.