This is a Rust re-implementation of tomnomnom's anew tool.
A simple command-line utility that reads from stdin and writes new (non-duplicate) lines to a destination file.
- Deduplication: Only writes lines that don't already exist in the destination file
- Sorting: Optional natural order sorting of lines
- Trimming: Optional whitespace trimming
- Rewrite mode: Clean up existing files by removing duplicates
- Dry run: Preview what would be written without making changes
- Quiet mode: Suppress output to stdout
cargo install --git https://github.com/wese/rust_anew.gitcargo build --releaseThe binary will be available at target/release/anew.
simple tool to write non-duplicate lines to a file
Usage: anew [OPTIONS] <PATH>
Arguments:
<PATH> destination file
Options:
-q, --quiet-mode do not output new lines to stdout
-s, --sort sort lines (natsort)
-t, --trim trim whitespaces
-r, --rewrite rewrite existing destination file to remove duplicates
--dry-run do not write to file, only output what would be written
-h, --help Print help
-V, --version Print version
echo -e "line1\nline2\nline1" | anew output.txt
# output.txt contains: line1, line2echo -e "banana\napple\ncherry" | anew --sort sorted.txt
# sorted.txt contains: apple, banana, cherryecho "new line" | anew -q existing.txt
# Writes to file but doesn't output to stdoutecho "potential duplicate" | anew --dry-run file.txt
# Shows what would be written without making changesanew --rewrite deduplicated.txt
# Removes all duplicate lines from deduplicated.txtcargo build # Debug build
cargo build --release # Optimized release buildcargo test # Run all tests
cargo test --verbose # Run tests with detailed outputcargo clippy # Run clippy linter
cargo clippy -- -D warnings # Treat warnings as errorscargo fmt # Format code
cargo fmt --check # Check formatting without changesMIT License - see LICENSE file for details.
Based on the original anew tool by Tom Hudson (@tomnomnom).