The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

4 lines
539 B

  1. #!/bin/bash
  2. # Reads a list of URLs from stdin, sorts by domain (in reverse label order), protocol, port, auth, and remainder of the URL.
  3. python3 -c 'import re, sys'$'\n''for line in sys.stdin:'$'\n'' line = line.strip()'$'\n'' m = re.search(r"^(?P<protocol>[^/]*)://(?P<auth>[^/@]*@)?(?P<domain>[^/]*?)(?P<port>:\d+)?(?P<rest>(?:/.*)?$)", line)'$'\n'' reversedomain = ".".join(reversed(m["domain"].split(".")))'$'\n'' print(line, reversedomain, m["protocol"], m["port"] or "", m["auth"] or "", m["rest"] or "")' | sort -k2 | cut -d' ' -f1