Skip to content

xa9e/setdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

setdiff

setdiff is a small command line utility to compare two line-oriented files using set operations.

Features

  • Set difference (A \ B or B \ A)
  • Set intersection
  • Set union
  • Symmetric difference with line prefixes
  • Unique lines (symmetric difference)

Installation

Build from source using Cargo:

cargo build --release

The compiled binary will be located at target/release/setdiff.

Usage

setdiff [OPTIONS] <FILE1> <FILE2>

Exactly one mode option must be provided:

  • --only-first – show lines only in FILE1 (A \ B).
  • --only-second – show lines only in FILE2 (B \ A).
  • --common – show the intersection of both files.
  • --union – show the union of both files.
  • --diff – display a symmetric difference with lines from FILE1 prefixed by < and lines from FILE2 prefixed by >.
  • --unique – list lines that appear in exactly one of the files.

Lines are sorted and deduplicated before the operation is performed.

Example

$ cat a.txt
apple
orange
banana

$ cat b.txt
banana
kiwi
orange


$ setdiff --only-first a.txt b.txt
apple

$ setdiff --unique a.txt b.txt
apple
kiwi

Testing

Run the test suite with:

cargo test

License

This project is released under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages