Created
November 30, 2021 01:42
-
-
Save hornc/5d52510c444874df9ef86bc957113306 to your computer and use it in GitHub Desktop.
Takes an input list of ISBN13s and counts how many belong to each of the possible regional agencies.
This file contains 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/bash | |
# Takes an input file argument (a sorted list of ISBN13s) | |
# and counts how many ISBNs are present belonging to each | |
# regional agency as listed in the official | |
# ISBN export_rangemessage.xml data. | |
wget -nc https://www.isbn-international.org/export_rangemessage.xml | |
while read prefix agency; do | |
echo -e "${agency}\t$(egrep -c ^$prefix $1)" | |
done < <(fgrep -A1 'Prefix' export_rangemessage.xml | | |
sed 's/<[^>]*>//g;s/-//g;s/^$/--/;s/^\s*/\t/' | | |
tr -d '\n' | | |
sed 's/$/--/;s/--/\n/g' | | |
sed -n 's/^\s//;/9780/,/ALL/p') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment