https://github.com/cleancut/headtail
head and tail simultaneously
https://github.com/cleancut/headtail
Last synced: 10 months ago
JSON representation
head and tail simultaneously
- Host: GitHub
- URL: https://github.com/cleancut/headtail
- Owner: CleanCut
- Created: 2022-08-24T17:17:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-14T23:36:55.000Z (about 1 year ago)
- Last Synced: 2025-03-30T00:05:40.836Z (11 months ago)
- Language: Rust
- Size: 92.8 KB
- Stars: 44
- Watchers: 3
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: license/APACHE
Awesome Lists containing this project
README
# headtail
`head` and `tail` simultaneously!
## Backstory
Not finding an existing utility to head _and_ tail the output, nor a good way to combine existing utilities even with the help of a [couple](https://github.com/jorendorff) [friends](https://github.com/bensherman) of [mine](https://github.com/CleanCut), we decided to make one. We ended up doing a "day of learning" session with about 50 other engineers from GitHub and collaboritively came up with a minimum viable solution that worked well!
Now it's a real utility that we keep improving. Go try it out!
## Contributing
Contributions are welcome! Here are some [good first issues](https://github.com/CleanCut/headtail/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) you could look into.
## Quick Start
You need to [have Rust installed](https://www.rust-lang.org/tools/install).
```shell
# Install latest *release* version of headtail
$ cargo install headtail
```
```
# Use it on a file - prints the first 10 and last 10 lines
$ headtail somebigfile.txt
# Pipe stdout to it - prints the first 10 and last 10 lines
$ somecommand | headtail
# Print the first 25 and last 5 lines of a file
$ headtail somebigfile.txt -H 25 -T 5
# Print the default amount of first lines, but only 3 last lines
$ headtail somebigfile.txt -T 3
# Do the default thing...but then keep tailing the file and print
# out anything new that is appended to it.
$ headtail somebigfile.txt -f
```
See `headtail -h` for a full list of command-line options.
## Development
```
# Run locally with arguments
$ cargo run -- YOUR_ARGS_GO_HERE
# Enable debug logging
$ RUST_LOG=trace cargo run -- YOUR_ARGS_GO_HERE
# Install local development version of headtail into your ~/.cargo/bin
$ cargo install --path .
```
## Software License
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [license/APACHE](license/APACHE) and [license/MIT](license/MIT).