make.country revision 1.1 1 1.1 christos #!/bin/sh
2 1.1 christos
3 1.1 christos hdr() {
4 1.1 christos echo '#' '$'NetBSD'$'
5 1.1 christos cat << _EOF
6 1.1 christos #
7 1.1 christos # ISO 3166-1 Country Codes
8 1.1 christos #
9 1.1 christos # The format of an entry is:
10 1.1 christos # <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
11 1.1 christos #
12 1.1 christos # Further information can be found at the ISO 3166 Maintenance Agency
13 1.1 christos # (ISO 3166/MA) web site,
14 1.1 christos # <http://www.iso.org/iso/en/prods-services/iso3166ma/index.html>.
15 1.1 christos #
16 1.1 christos # FIPS 10-4 codes compiled from several sources, including
17 1.1 christos # http://www.statoids.com/wab.html
18 1.1 christos #
19 1.1 christos # ISO 3166-1 entities without exactly one corresponding FIPS code have a
20 1.1 christos # blank entry in the column. FIPS 10-4 codes without a corresponding
21 1.1 christos # ISO 3166-1 entity are excluded.
22 1.1 christos #
23 1.1 christos # This list is up-to-date as of $(date +%Y-%m-%d)
24 1.1 christos #
25 1.1 christos _EOF
26 1.1 christos }
27 1.1 christos
28 1.1 christos I1=http://www.statoids.com/wab.html
29 1.1 christos O1=/tmp/wab.$$
30 1.1 christos I2=http://www.iso.org/iso/list-en1-semic-3.txt
31 1.1 christos O2=/tmp/list.$$
32 1.1 christos trap "rm -f wab.html list-en1-semic-3.txt $O1 $O2" 0 1 2 3 15
33 1.1 christos ftp $I1
34 1.1 christos ftp $I2
35 1.1 christos
36 1.1 christos grep '<tr class="[oe]">' wab.html |
37 1.1 christos sed -e 's,<tr class="."><td>,,g' \
38 1.1 christos -e 's,\ ,,g' \
39 1.1 christos -e 's,<code>,,g' \
40 1.1 christos -e 's,</code>,,g' \
41 1.1 christos -e 's,<br>, ,g' \
42 1.1 christos -e 's,</td><td>, ,g' \
43 1.1 christos -e 's,,Aa,g' \
44 1.1 christos -e 's,,o,g' \
45 1.1 christos -e 's,</td></tr>,,g' |
46 1.1 christos awk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
47 1.1 christos grep -v href= |
48 1.1 christos sort > $O1
49 1.1 christos
50 1.1 christos grep ';[A-Z][A-Z]' list-en1-semic-3.txt |
51 1.1 christos tr -d '\015' |
52 1.1 christos awk -F ';' '{ print $2 }' |
53 1.1 christos sort > $O2
54 1.1 christos
55 1.1 christos hdr
56 1.1 christos join -t ' ' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort
57