snippets/old_snippets/remove-common-lines.en.md

55 lines
No EOL
990 B
Markdown

---
title: "remove common lines with comm"
seo_description: "How to remove common lines from files using the comm command"
date: 2023-05-24T12:52:11+02:00
draft: false
snippet_types:
- comm
---
With help of ChatGPT I discovered this unix gem today.
Given two files
main_deck.txt:
```
1 Abzan Charm
1 Arcane Bombardment
1 Arcane Sanctum
1 Arcane Signet
1 Archmage Emeritus
1 Bant Charm
1 Boros Charm
1 Bring to Light
1 Brokers Charm
1 Brokers Confluence
```
considering.txt:
```
1 Abzan Charm
1 Arcane Sanctum
1 Taigam, Ojutai Master
1 Archmage Emeritus
1 Boros Charm
1 Tamanoa
1 Time Wipe
1 Trap Essence
1 Brokers Confluence
```
running
```shell
$ comm -23 <(cat considering.txt | sort) <(cat main_deck.txt | sort)
1 Taigam, Ojutai Master
1 Tamanoa
1 Time Wipe
1 Trap Essence
```
Returns a list of cards that are unique to the considering.txt.
If your text files are sorted you can skip the `<(cat ..)` magic.
And yes. I'm using the cli two help build Magic the Gathering Decks!