Git Product home page Git Product logo

commr's Introduction

commr

Rust version of comm

Synopsis

commr reads two files and reports the lines of text that are common to both and the lines that are unique to each. These are set operations where the common lines are the intersection of the two files and the unique lines are the difference. If you are familiar with databases, you might also consider these as types of join operations.

$ commr --help
Rust version of comm

Usage: commr [OPTIONS] <FILE1> <FILE2>

Arguments:
  <FILE1>  Input file 1
  <FILE2>  Input file 2

Options:
  -1                                  Show column 1
  -2                                  Show column 2
  -3                                  Show column 3
  -i, --insensitive                   Case-insensitive comparison of lines
  -d, --output-delimiter <DELIMITER>  Output delimiter [default: "\t"]
  -h, --help                          Print help
  -V, --version                       Print version

The output is three columns of text separated by the --output-delimiter:

  1. The lines unique to file1
  2. The lines unique to file2
  3. The lines common to both files

For instance, given these files:

$ cat tests/inputs/file1.txt
a
b
c
d
$ cat tests/inputs/file2.txt
B
c

The default output will be:

$ commr tests/inputs/file1.txt tests/inputs/file2.txt
	B
a
b
		c
d

The output again with a delimiter to make it easier to see the columns:

$ commr tests/inputs/file1.txt tests/inputs/file2.txt -d='--->'
--->B
a
b
--->--->c
d

One of the input files may be STDIN (standard in) as indicated by a dash (-):

$ commr tests/inputs/file1.txt - -d='--->' <tests/inputs/file2.txt
--->B
a
b
--->--->c
d

Both inputs may not be STDIN:

$ commr - -
Both input files cannot be STDIN ("-")

Use the -i|--insensitive flag for case-insensitive comparisons:

$ commr tests/inputs/file1.txt tests/inputs/file2.txt -i
a
		b
		c
d

Use -1 to see just the first column:

$ commr -1 tests/inputs/file1.txt tests/inputs/file2.txt
a
b
d

Use -2 to see just the first column:

$ commr -2 tests/inputs/file1.txt tests/inputs/file2.txt
B

Use -3 to see just the first column:

$ commr -3 tests/inputs/file1.txt tests/inputs/file2.txt
c

Use any combination of -1, -2, or -3 to show columns:

$ commr -d "|" -13 tests/inputs/file1.txt tests/inputs/file2.txt
a
b
|c
d

Rationale

The BSD/GNU versions of comm use the -1, -2, and -3 flags to suppress the printing of the columns. This Rust version inverts the meanings to mean these columns should be shown. Like the wc program, the default will be to show all the columns unless the user indicates which columns they wish to see.

Author

Ken Youens-Clark [email protected]

commr's People

Contributors

kyclark avatar

Stargazers

barrett avatar Stef avatar Adam Chalkley avatar

Watchers

 avatar  avatar Adam Chalkley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.