|
| 1 | +# Compare |
| 2 | + |
| 3 | +Compare IP sets pairwise and print CSV with overlap statistics. |
| 4 | + |
| 5 | +Three comparison modes are available: |
| 6 | + |
| 7 | +## Compare all (`--compare`) |
| 8 | + |
| 9 | +Compare every file with every other file. |
| 10 | + |
| 11 | +``` |
| 12 | +# list-a.txt # list-b.txt # list-c.txt |
| 13 | +10.0.0.0/24 10.0.0.128/25 10.0.0.0/16 |
| 14 | +10.0.1.0/24 10.0.2.0/24 172.16.0.0/12 |
| 15 | +192.168.1.0/24 192.168.1.0/24 |
| 16 | +``` |
| 17 | + |
| 18 | +``` |
| 19 | +$ iprange --compare --header list-a.txt list-b.txt list-c.txt |
| 20 | +name1,name2,entries1,entries2,ips1,ips2,combined_ips,common_ips |
| 21 | +list-a.txt,list-b.txt,2,3,768,640,1024,384 |
| 22 | +list-a.txt,list-c.txt,2,2,768,1114112,1114368,512 |
| 23 | +list-b.txt,list-c.txt,3,2,640,1114112,1114368,384 |
| 24 | +``` |
| 25 | + |
| 26 | +**Columns**: name1, name2, entries in each, unique IPs in each, combined (union) IPs, common (intersection) IPs. |
| 27 | + |
| 28 | +## Compare first (`--compare-first`) |
| 29 | + |
| 30 | +Compare the first file against each subsequent file. |
| 31 | + |
| 32 | +``` |
| 33 | +$ iprange --compare-first --header list-a.txt list-b.txt list-c.txt |
| 34 | +name,entries,unique_ips,common_ips |
| 35 | +list-b.txt,3,640,384 |
| 36 | +list-c.txt,2,1114112,512 |
| 37 | +``` |
| 38 | + |
| 39 | +This is useful for checking how much of a reference list overlaps with each of several other lists. |
| 40 | + |
| 41 | +## Compare next (`--compare-next`) |
| 42 | + |
| 43 | +**Positional**: compare files before the option against files after it. |
| 44 | + |
| 45 | +``` |
| 46 | +$ iprange list-a.txt --compare-next list-b.txt list-c.txt --header |
| 47 | +name1,name2,entries1,entries2,ips1,ips2,combined_ips,common_ips |
| 48 | +list-a.txt,list-b.txt,2,3,768,640,1024,384 |
| 49 | +list-a.txt,list-c.txt,2,2,768,1114112,1114368,512 |
| 50 | +``` |
| 51 | + |
| 52 | +Only `list-a.txt` (before `--compare-next`) is compared against `list-b.txt` and `list-c.txt` (after it). |
| 53 | + |
| 54 | +## Naming files in CSV output |
| 55 | + |
| 56 | +Use `as NAME` after a filename to set a custom name in the CSV: |
| 57 | + |
| 58 | +``` |
| 59 | +$ iprange --count-unique-all --header list-a.txt as "Blocklist A" list-b.txt as "Blocklist B" |
| 60 | +name,entries,unique_ips |
| 61 | +Blocklist A,2,768 |
| 62 | +Blocklist B,3,640 |
| 63 | +``` |
| 64 | + |
| 65 | +## CSV header |
| 66 | + |
| 67 | +All CSV modes default to no header. Add `--header` to include column names as the first row. |
0 commit comments