Cliamp
GitHub RepoImpressions85
View on GitHub
@githubprojectsPost Author

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..20 prints lines 10 through 20.
  • Character clamping: cliamp --char 100..200 gives you characters 100 to 200.
  • Smart ranges: Use negative indices like -20..-1 to get the last 20 lines. Or ..50 for the first 50. Or 10.. for everything after line 10.

It's that straightforward. No learning curve, no config files.

Why It's Cool

  1. Zero dependencies. It's a single Rust binary. You can drop it in your PATH and forget about it.
  2. Negative indexing. This is the killer feature. head -n 20 gives you the first 20 lines. tail -n 20 gives 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 piping head into tail into awk.
  3. Character mode. Ever tried to preview a binary file or a huge single-line JSON? head is useless. Cliamp's --char flag lets you grab a chunk of characters directly. Perfect for inspecting blobs or debugging serialized data.
  4. Error‑friendly. If you ask for a range that's out of bounds, Cliamp doesn't crash—it just outputs what it can. No panics.
  5. Tiny footprint. The binary is around 1MB. No Node, no Python, no runtime overhead.

How to Try It

The fastest way is to grab the binary from the releases page. Or if you have Rust installed, build it yourself:

cargo install cliamp

Then test it:

# Generate 100 lines of test data
seq 1 100 | cliamp 10..30

# Get last 10 lines
seq 1 100 | cliamp -10..-1

# Grab a slice of characters from a file
cliamp --char 0..500 < huge.json

That's it. No options to memorize.

Final Thoughts

Cliamp is one of those tools that feels obvious after you use it. It doesn't try to solve every problem—it just nails a specific one. If you're someone who spends a lot of time in the terminal looking at logs, JSON dumps, or anything that scrolls forever, this will save you from writing ugly pipelines. The author, Bjarne, put thought into the range syntax, and it shows.

Give it a try next time you're staring at a wall of text. Your fingers will thank you.


Found this useful? Follow us at @githubprojects for more developer tools and open-source highlights.

Back to Projects
Last updated: May 31, 2026 at 05:30 PM