2012-03-16 17:33:49 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
hdr() {
|
|
|
|
|
echo '#' '$'NetBSD'$'
|
|
|
|
|
cat << _EOF
|
|
|
|
|
#
|
|
|
|
|
# ISO 3166-1 Country Codes
|
|
|
|
|
#
|
|
|
|
|
# The format of an entry is:
|
|
|
|
|
# <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
|
|
|
|
|
#
|
|
|
|
|
# Further information can be found at the ISO 3166 Maintenance Agency
|
2013-12-06 12:04:52 +01:00
|
|
|
|
# (ISO 3166/MA) web site, <http://www.iso.org/iso/country_codes>.
|
2012-03-16 17:33:49 +01:00
|
|
|
|
#
|
|
|
|
|
# FIPS 10-4 codes compiled from several sources, including
|
|
|
|
|
# http://www.statoids.com/wab.html
|
|
|
|
|
#
|
|
|
|
|
# ISO 3166-1 entities without exactly one corresponding FIPS code have a
|
|
|
|
|
# blank entry in the column. FIPS 10-4 codes without a corresponding
|
|
|
|
|
# ISO 3166-1 entity are excluded.
|
|
|
|
|
#
|
|
|
|
|
# This list is up-to-date as of $(date +%Y-%m-%d)
|
|
|
|
|
#
|
|
|
|
|
_EOF
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
|
I1=wab.html
|
|
|
|
|
U1=http://www.statoids.com/$I1
|
2012-03-16 17:33:49 +01:00
|
|
|
|
O1=/tmp/wab.$$
|
2013-12-06 12:04:52 +01:00
|
|
|
|
I2=country_names_and_code_elements_txt
|
|
|
|
|
U2=http://www.iso.org/iso/$I2
|
2012-03-16 17:33:49 +01:00
|
|
|
|
O2=/tmp/list.$$
|
2013-12-06 12:04:52 +01:00
|
|
|
|
trap "rm -f $I1 $I2 $O1 $O2" 0 1 2 3 15
|
|
|
|
|
ftp $U1
|
|
|
|
|
ftp $U2
|
2012-03-16 17:33:49 +01:00
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
|
grep '<tr class="[oe]">' $I1 |
|
2012-03-16 17:33:49 +01:00
|
|
|
|
sed -e 's,<tr class="."><td>,,g' \
|
|
|
|
|
-e 's,\ ,,g' \
|
|
|
|
|
-e 's,<code>,,g' \
|
|
|
|
|
-e 's,</code>,,g' \
|
|
|
|
|
-e 's,<br>, ,g' \
|
|
|
|
|
-e 's,</td><td>, ,g' \
|
|
|
|
|
-e 's,<2C>,Aa,g' \
|
|
|
|
|
-e 's,<2C>,o,g' \
|
|
|
|
|
-e 's,</td></tr>,,g' |
|
|
|
|
|
awk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
|
|
|
|
|
grep -v href= |
|
|
|
|
|
sort > $O1
|
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
|
grep ';[A-Z][A-Z]' $I2 |
|
2012-03-16 17:33:49 +01:00
|
|
|
|
tr -d '\015' |
|
|
|
|
|
awk -F ';' '{ print $2 }' |
|
|
|
|
|
sort > $O2
|
|
|
|
|
|
|
|
|
|
hdr
|
|
|
|
|
join -t ' ' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort
|