Cliamp: A CLI Tool That Clamps Your Outputs, But Not Like You Think
You know that moment when you're piping a command and the output is either too much, too little, or just... noisy? Cliamp is a tiny CLI utility that solves a weirdly specific problem: it clamps the number of lines or characters in your output. Think of it as head and tail had a baby, but with a smarter, more flexible approach.
It's one of those tools you didn't know you needed until you're debugging a 10,000-line JSON dump and just want to see the first 20 lines and the last 10. Or maybe you're running a script that spits out a wall of logs and you need the middle chunk. Cliamp does that.
What It Does
Cliamp reads from stdin (or a file) and lets you specify a range of lines or characters to output. You give it a clamp—like 1..20 or 10..-5—and it spits out only that slice. Simple, clean, no fluff.
Here's the core idea:
- Line clamping:
cat bigfile.log | cliamp 10..20prints lines 10 through 20. - Character clamping:
cliamp --char 100..200gives you characters 100 to 200. - Smart ranges: Use negative indices like
-20..-1to get the last 20 lines. Or..50for the first 50. Or10..for everything after line 10.
It's that straightforward. No learning curve, no config files.
Why It's Cool
- Zero dependencies. It's a single Rust binary. You can drop it in your
PATHand forget about it. - Negative indexing. This is the killer feature.
head -n 20gives you the first 20 lines.tail -n 20gives you the last 20. But what if you want lines 10 through 20? Or lines 10 through the end? Cliamp does all of that with one command. No pipingheadintotailintoawk. - Character mode. Ever tried to preview a binary file or a huge single-line JSON?
headis useless. Cliamp's--charflag lets you grab a chunk of characters directly. Perfect for inspecting blobs or debugging serialized data. - Error‑friendly. If you ask for a range that's out of bounds, Cliamp doesn't crash—it just outputs what it