{"id":37224516,"url":"https://github.com/marcosy/sop","last_synced_at":"2026-01-15T01:42:03.285Z","repository":{"id":62867583,"uuid":"556219563","full_name":"marcosy/sop","owner":"marcosy","description":"A command line tool to perform set operations with files","archived":false,"fork":false,"pushed_at":"2022-11-06T21:41:03.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-21T14:59:57.933Z","etag":null,"topics":["calculator","cli","difference","intersection","math","set-operations","sets","union"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcosy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-23T10:48:15.000Z","updated_at":"2023-11-27T09:14:28.000Z","dependencies_parsed_at":"2022-11-08T06:49:31.667Z","dependency_job_id":null,"html_url":"https://github.com/marcosy/sop","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/marcosy/sop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosy%2Fsop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosy%2Fsop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosy%2Fsop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosy%2Fsop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcosy","download_url":"https://codeload.github.com/marcosy/sop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosy%2Fsop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculator","cli","difference","intersection","math","set-operations","sets","union"],"created_at":"2026-01-15T01:42:02.574Z","updated_at":"2026-01-15T01:42:03.261Z","avatar_url":"https://github.com/marcosy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sop\n\n[![Build](https://github.com/marcosy/sop/actions/workflows/build.yml/badge.svg)](https://github.com/marcosy/sop/actions/workflows/build.yml)\n[![coverage](https://img.shields.io/badge/coverage-98.9%25-brightgreen)](https://github.com/marcosy/sop/actions/workflows/build.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/marcosy/sop)](https://goreportcard.com/report/github.com/marcosy/sop)\n[![License](https://img.shields.io/github/license/marcosy/sop?color=brightgreen)](./LICENSE)\n\n_A command line tool to perform **s**et **op**erations with files_\n\n## Installation\n\nYou can install `sop` using `homebrew`, `go install` or building it from source.\n\n### Homebrew\n\n```bash\n\u003e brew install marcosy/tap/sop\n```\n\n### Go Install\n\n```bash\n\u003e go install github.com/marcosy/sop\n```\n\nRemember to add `GOPATH/bin` to your `PATH`:\n\n```bash\n\u003e export PATH=\"$GOPATH/bin:$PATH\"\n```\n\n### Build from source\n\nYou can also build `sop` from source, just run:\n\n```bash\n\u003e git clone git@github.com:marcosy/sop.git\n\u003e make build\n```\n\nThe binary will be saved at `./bin/sop`. For other targets, run `make help`.\n\n## Usage\n\n`sop` considers files as sets of elements and performs set operations with those files.\n\n```bash\nsop [options] \u003coperation\u003e \u003cfilepath A\u003e \u003cfilepath B\u003e\n```\n\n- **operation** can be one of:\n  - `union`: Print elements that exists in file A or file B\n\n  - `intersection`: Print elements that exists in file A and file B\n  \n  - `difference`: Print elements that exists in file A and do not exist in file B\n\n- **filepath A** and **filepath B** are the filepaths to the files containing\nthe elements to operate with. Elements are delimited by a separator string which\nby default is `\"\\n\"`.\n\n- **options** can be:\n  - `-s`: String used as element separator (default `\"\\n\"`)\n\n## Examples\n\nGiven two files A (`fileA.txt`) and B (`fileB.txt`):\n\n`fileA.txt`:\n\n```txt\nFox\nDuck\nDog\nCat\n```\n\n`fileB.txt`:\n\n```txt\nDog\nCat\nCow\nGoat\n```\n\n`sop` performs set operations with the files.\n\n### Operations\n\nThe available operations are: union, intersection and difference.\n\n#### Union\n\nThe [union](https://en.wikipedia.org/wiki/Union_(set_theory)) of two sets A and B is the set of elements which are in A, in B, or in both A and B.\n\n```bash\n\u003e sop union fileA.txt fileB.txt\nFox\nDuck\nDog\nCat\nCow\nGoat\n```\n\n#### Intersection\n\nThe [intersection](https://en.wikipedia.org/wiki/Intersection_(set_theory)) of two sets A and B is the set containing all elements of A that also belong to B or equivalently, all elements of B that also belong to A.\n\n```bash\n\u003e sop intersection fileA.txt fileB.txt\nDog\nCat\n```\n\n#### Difference\n\nThe [difference](https://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement) (a.k.a. relative complement) of A and B, is the set of all elements in A that are not in B.\n\n```bash\n\u003e sop difference fileA.txt fileB.txt\nFox\nDuck\n```\n\n### Considerations\n\n#### Separator\n\nThe separator character used to delimitate elements is set by default to the new\nline character (`\\n`) but can also be configured using the flag `-s`:\n\n```bash\n\u003e sop -s , union fileA.csv fileB.csv \n```\n\n#### Sorting\n\nThe result sets are not ordered by default, so consecutive executions may return\nelements in different order. To obtain a consistent order pipe the output of `sop`\nto `sort`:\n\n```bash\n\u003e sop intersection fileA.txt fileB.txt | sort\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosy%2Fsop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcosy%2Fsop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosy%2Fsop/lists"}