linsel 0.1.0-alpha.1

A small program to print out selected lines of a file
Documentation
  • Coverage
  • 47.37%
    9 out of 19 items documented1 out of 6 items with examples
  • Size
  • Source code size: 58.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.34 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • diazona

linsel

line selector

A small program that prints out selected lines from its input.

Installation

Install in the standard way for Rust programs:

cargo install --bins linsel

Usage

linsel takes any number of arguments of the form <start>-<end>/<step>, which means "print out every <step>th line from <start> to <end>, inclusive". The hyphen can also be replaced with a colon: <start>:<end>/<step>.

Line numbers are 1-based: the first line of input is numbered 1, not 0. Any line selected by any of the arguments will be printed, but each line is only printed once.

$ seq 20 | linsel 4-10/2 8-17/3
4
6
8
10
11
14
17

There are various abbreviated forms:

  • If <start> is omitted, printing begins with the first line of input.
  • If <end> is omitted, printing extends all the way to the last line of input.
  • If /<step> is omitted, the step defaults to 1.
  • A single number <n> means exactly line <n>, equivalent to <n>-<n>/1.
$ seq 10 | linsel -2
1
2
$ seq 10 | linsel 9-
9
10
$ seq 10 | linsel 4
4

Recipes

  • head -n <NUM> is equivalent to linsel -<NUM>
  • head -n -<NUM> is equivalent to linsel <NUM>-

Why "linsel"?

Plus the name rhymes with "tinsel" and I think that's kind of cute. But really, it's mostly because naming is hard, this one was unclaimed, and I didn't come up with anything better in a few days.