11.1Schristos#!/bin/sh
21.1Schristos
31.1Schristoshdr() {
41.1Schristosecho '#' '$'NetBSD'$'
51.1Schristoscat << _EOF
61.1Schristos#
71.1Schristos# ISO 3166-1 Country Codes
81.1Schristos#
91.1Schristos# The format of an entry is:
101.1Schristos# <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
111.1Schristos#
121.1Schristos# Further information can be found at the ISO 3166 Maintenance Agency
131.2Sginsbach# (ISO 3166/MA) web site, <http://www.iso.org/iso/country_codes>.
141.1Schristos#
151.1Schristos# FIPS 10-4 codes compiled from several sources, including
161.1Schristos# http://www.statoids.com/wab.html
171.1Schristos#
181.1Schristos# ISO 3166-1 entities without exactly one corresponding FIPS code have a
191.1Schristos# blank entry in the column. FIPS 10-4 codes without a corresponding
201.1Schristos# ISO 3166-1 entity are excluded.
211.1Schristos#
221.1Schristos# This list is up-to-date as of $(date +%Y-%m-%d)
231.1Schristos#
241.1Schristos_EOF
251.1Schristos}
261.1Schristos
271.2SginsbachI1=wab.html
281.2SginsbachU1=http://www.statoids.com/$I1
291.1SchristosO1=/tmp/wab.$$
301.2SginsbachI2=country_names_and_code_elements_txt
311.2SginsbachU2=http://www.iso.org/iso/$I2
321.1SchristosO2=/tmp/list.$$
331.2Sginsbachtrap "rm -f $I1 $I2 $O1 $O2" 0 1 2 3 15
341.2Sginsbachftp $U1
351.2Sginsbachftp $U2
361.1Schristos
371.2Sginsbachgrep '<tr class="[oe]">' $I1 |
381.1Schristossed -e 's,<tr class="."><td>,,g' \
391.1Schristos    -e 's,\&nbsp;,,g' \
401.1Schristos    -e 's,<code>,,g' \
411.1Schristos    -e 's,</code>,,g' \
421.1Schristos    -e 's,<br>, ,g' \
431.1Schristos    -e 's,</td><td>,	,g' \
441.1Schristos    -e 's,�,Aa,g' \
451.1Schristos    -e 's,�,o,g' \
461.1Schristos    -e 's,</td></tr>,,g' |
471.1Schristosawk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
481.1Schristosgrep -v href= |
491.1Schristossort > $O1
501.1Schristos
511.2Sginsbachgrep ';[A-Z][A-Z]' $I2 |
521.1Schristostr -d '\015' |
531.1Schristosawk -F ';' '{ print $2 }' |
541.1Schristossort > $O2
551.1Schristos
561.1Schristoshdr
571.1Schristosjoin -t '	' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort
58