https://github.com/ysf/anewer
anewer appends lines from stdin to a file if they don't already exist in the file. This is a rust version of https://github.com/tomnomnom/anew
https://github.com/ysf/anewer
bugbounty cli rust stdin stdout tool uniq
Last synced: 4 months ago
JSON representation
anewer appends lines from stdin to a file if they don't already exist in the file. This is a rust version of https://github.com/tomnomnom/anew
- Host: GitHub
- URL: https://github.com/ysf/anewer
- Owner: ysf
- License: gpl-3.0
- Created: 2020-11-05T15:31:09.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-10-17T15:41:21.000Z (about 3 years ago)
- Last Synced: 2024-10-07T01:47:46.762Z (about 1 year ago)
- Topics: bugbounty, cli, rust, stdin, stdout, tool, uniq
- Language: Rust
- Homepage: https://github.com/ysf/anewer
- Size: 55.7 KB
- Stars: 58
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - ysf/anewer - anewer appends lines from stdin to a file if they don't already exist in the file. This is a rust version of https://github.com/tomnomnom/anew (Rust)
README
# anewer [![crates.io][crates-img]][crates] [![@ysfr][twitter-img]][twitter]
anewer appends lines from stdin to a file if they don't already exist in the file. You could also use it as `uniq` without `sort`. This is a rust version of [tomnomnom/anew](https://github.com/tomnomnom/anew). It makes use of [tkaitchuck/aHash](https://github.com/tkaitchuck/aHash) to cut down runtime to ~50%. Since only hashed lines are held in memory, it cuts down memory usage for inputs with long lines. Which is similar how [`huniq`](https://crates.io/crates/huniq) works.
[twitter-img]: https://img.shields.io/badge/twitter-@ysfr-blue.svg
[twitter]: https://twitter.com/ysfr
[crates-img]: https://img.shields.io/crates/v/anewer.svg
[crates]: https://crates.io/crates/anewer
## Usage
```
$ anewer -h
USAGE:
anewer [FLAGS] [filename]
FLAGS:
-n, --dry-run Dry run, will leave the file as it is
-h, --help Prints help information
-v, --invert Invert the sense of matching
-q, --quiet Quiet, won't print to stdout
-V, --version Prints version information
ARGS:
```
## Installation
```
cargo install anewer
```
#### Add unknown elements of newthings.txt to things.txt
```
$ cat things.txt
Zero
One
Two
$ cat newthings.txt
One
Two
Three
Four
$ cat newthings.txt | anewer things.txt
Three
Four
$ cat things.txt
Zero
One
Two
Three
Four
```
#### Or use it as simple uniq without sort
```
$ cat list.txt
One
One
Two
Two
Three
Four
Three
Four
$ cat list.txt | anewer
One
Two
Three
Four
```
# License
GPLv3+