#first-line #command-line #text #linux-command #head #tail #filter

bin+lib aki-unbody

output first or last n lines, like a head and tail of linux command

19 releases

0.1.18 Jan 11, 2023
0.1.17 Jun 17, 2022
0.1.16 May 21, 2022
0.1.15 Nov 15, 2021
0.1.5 Mar 22, 2021

#1146 in Text processing

Download history 8/week @ 2024-02-19 6/week @ 2024-02-26 4/week @ 2024-03-11 49/week @ 2024-04-01

53 downloads per month
Used in aki-txpr-macro

MIT/Apache

27KB
394 lines

aki-unbody

crate Docs Rust Version Apache2/MIT licensed

output first or last n lines, like a head and tail of linux command.

Features

  • output first or last n lines, like a head and tail of linux command.
  • minimum support rustc 1.56.1 (59eed8a2a 2021-11-01)

Command help

aki-unbody --help
Usage:
  aki-unbody [options]

output first or last n lines, like a head and tail of linux command.

Options:
  -h, --head <num>      output the first <num> lines.
  -t, --tail <num>      output the last <num> lines.
  -i, --inverse         output the body, except for head and tail.

  -H, --help        display this help and exit
  -V, --version     display version information and exit

Examples:
  Outputs first 2 lines:
    cat file1.txt | aki-unbody --head 2
  Outputs last 2 lines:
    cat file1.txt | aki-unbody --tail 2
  Outputs body, except for first 2 lines and last 2 lines:
    cat file1.txt | aki-unbody --head 2 --tail 2 --inverse

Quick install

  1. you can install this into cargo bin path:
cargo install aki-unbody
  1. you can build debian package:
cargo deb

and install .deb into your local repository of debian package.

Examples

The input data used in this example looks like this:

cat file1.txt

result output:

LN:0001,text
LN:0002,text
LN:0003,text
LN:0004,text
LN:0005,text
LN:0006,text

Example 1: output head

Outputs first 2 lines.

command line:

cat file1.txt | aki-unbody --head 2

result output:

LN:0001,text
LN:0002,text

Example 2: output tail

Outputs last 2 lines.

command line:

cat file1.txt | aki-unbody --tail 2

result output:

LN:0005,text
LN:0006,text

Example 3: output head and tail

Outputs first 2 lines and last 2 lines.

command line:

cat file1.txt | aki-unbody --head 2 --tail 2

result output:

LN:0001,text
LN:0002,text
LN:0005,text
LN:0006,text

Example 4: output body, except for head and tail

Outputs body, except for first 2 lines and last 2 lines.

command line:

cat file1.txt | aki-unbody --head 2 --tail 2 --inverse

result output:

LN:0003,text
LN:0004,text

Library example

See fn execute() for this library examples.

Changelogs

This crate's changelog here.

License

This project is licensed under either of

at your option.

Dependencies

~1MB
~29K SLoC