项目作者: alexdelorenzo

项目描述 :
Return or exclude the nth item via stdin
高级语言: Rust
项目地址: git://github.com/alexdelorenzo/nth_rs.git
创建时间: 2020-08-31T18:58:46Z
项目社区:https://github.com/alexdelorenzo/nth_rs

开源协议:GNU Affero General Public License v3.0

下载


nth_rs

Return or exclude the nth lines supplied from stdin as output on stdout. See the Python version of this utility here: nth_py.

This project utilizes byte_lines to iterate over standard input as lines of bytes, instead of strings or individual bytes.

Install

  1. cargo install nth_rs

Usage

  1. $ dmesg | nth_rs 0 1 2 3
  2. [ 4.095065] xhci-hcd xhci-hcd.3.auto: xHCI Host Controller
  3. [ 4.100328] xhci-hcd xhci-hcd.3.auto: new USB bus registered, assigned bus number 4
  4. [ 4.107985] xhci-hcd xhci-hcd.3.auto: Host supports USB 3.0 SuperSpeed
  5. [ 4.109677] mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)

To better illustrate, let’s enumerate each line of stdin:

  1. $ dmesg | count | nth_rs 0 1 2 3
  2. 0 [ 4.095065] xhci-hcd xhci-hcd.3.auto: xHCI Host Controller
  3. 1 [ 4.100328] xhci-hcd xhci-hcd.3.auto: new USB bus registered, assigned bus number 4
  4. 2 [ 4.107985] xhci-hcd xhci-hcd.3.auto: Host supports USB 3.0 SuperSpeed
  5. 3 [ 4.109677] mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)

Help

  1. $ nth_rs --help
  2. nth 0.2.0
  3. AlexDeLorenzo.dev
  4. Return the contents of stdin from the line numbers supplied as arguments.
  5. USAGE:
  6. nth_rs [FLAGS] <LINES>...
  7. FLAGS:
  8. -h, --help Prints help information
  9. -r, --reverse Write every line, except the line numbers supplied as LINES, from stdin to stdout.
  10. -V, --version Prints version information
  11. ARGS:
  12. <LINES>... Line numbers to select

License

See LICENSE. If you’d like to use this project with a different license, please get in touch.