Created
October 3, 2025 16:01
-
-
Save igolaizola/6e853f76d1d6c5d44f5d323de815d2d4 to your computer and use it in GitHub Desktop.
Fetches IANA Private Enterprise Numbers and prints a CSV (id,organization,contact,email) to stdout, converting obfuscated & emails to @.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| curl -fsSL 'https://www.iana.org/assignments/enterprise-numbers.txt' | awk ' | |
| BEGIN { | |
| OFS=","; print "id,organization,contact,email" | |
| } | |
| function trim(s){ sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } | |
| function csvq(s){ gsub(/"/, "\"\"", s); return "\"" s "\"" } | |
| # New record: a line with only digits | |
| /^[0-9]+[ \t]*$/ { | |
| if (id != "") print csvq(id), csvq(org), csvq(contact), csvq(email) | |
| id=trim($0); org=""; contact=""; email="" | |
| next | |
| } | |
| # Organization: 2 leading spaces | |
| /^ [^ ]/ { org=trim($0); next } | |
| # Contact: 4 leading spaces | |
| /^ [^ ]/ { contact=trim($0); next } | |
| # Email: 6 leading spaces (IANA uses & for @) | |
| /^ / { | |
| e=trim($0); gsub(/&/, "@", e); email=e; next | |
| } | |
| END { | |
| if (id != "") print csvq(id), csvq(org), csvq(contact), csvq(email) | |
| } | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment