Last active
December 1, 2022 16:55
-
-
Save 0xtavi/597eda0184cbc0aa3d02fe08edeed15c to your computer and use it in GitHub Desktop.
Shell script for extracting unique directories from a file containing urls line by line
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
#!/bin/sh | |
# Inspired from https://twitter.com/rez0__ | |
# Usage ./unique_directories.sh urls.txt | |
rm unique_urls.txt > /dev/null | |
cat $1 | rev | cut -d/ -f2- | rev | sort -u | anew unique_urls.txt > /dev/null | |
for i in {1..10}; do cat unique_urls.txt | rev | cut -d/ -f2- | rev | sort -u | anew unique_urls.txt > /dev/null; done | |
sed -i "" "s/$/\//g" unique_urls.txt | |
sed -i "" "/^\/$/d" unique_urls.txt | |
sed -e "/\/\/$/d" unique_urls.txt | grep -Ev "(:/|://)$" | sort -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment