xref: /minix3/share/misc/make.country (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
15737b690SBen Gras#!/bin/sh
25737b690SBen Gras
35737b690SBen Grashdr() {
45737b690SBen Grasecho '#' '$'NetBSD'$'
55737b690SBen Grascat << _EOF
65737b690SBen Gras#
75737b690SBen Gras# ISO 3166-1 Country Codes
85737b690SBen Gras#
95737b690SBen Gras# The format of an entry is:
105737b690SBen Gras# <Name><TAB><Alpha-2-code><TAB><Alpha-3-code><TAB><Numeric-3-code><TAB><FIPS>
115737b690SBen Gras#
125737b690SBen Gras# Further information can be found at the ISO 3166 Maintenance Agency
13*84d9c625SLionel Sambuc# (ISO 3166/MA) web site, <http://www.iso.org/iso/country_codes>.
145737b690SBen Gras#
155737b690SBen Gras# FIPS 10-4 codes compiled from several sources, including
165737b690SBen Gras# http://www.statoids.com/wab.html
175737b690SBen Gras#
185737b690SBen Gras# ISO 3166-1 entities without exactly one corresponding FIPS code have a
195737b690SBen Gras# blank entry in the column. FIPS 10-4 codes without a corresponding
205737b690SBen Gras# ISO 3166-1 entity are excluded.
215737b690SBen Gras#
225737b690SBen Gras# This list is up-to-date as of $(date +%Y-%m-%d)
235737b690SBen Gras#
245737b690SBen Gras_EOF
255737b690SBen Gras}
265737b690SBen Gras
27*84d9c625SLionel SambucI1=wab.html
28*84d9c625SLionel SambucU1=http://www.statoids.com/$I1
295737b690SBen GrasO1=/tmp/wab.$$
30*84d9c625SLionel SambucI2=country_names_and_code_elements_txt
31*84d9c625SLionel SambucU2=http://www.iso.org/iso/$I2
325737b690SBen GrasO2=/tmp/list.$$
33*84d9c625SLionel Sambuctrap "rm -f $I1 $I2 $O1 $O2" 0 1 2 3 15
34*84d9c625SLionel Sambucftp $U1
35*84d9c625SLionel Sambucftp $U2
365737b690SBen Gras
37*84d9c625SLionel Sambucgrep '<tr class="[oe]">' $I1 |
385737b690SBen Grassed -e 's,<tr class="."><td>,,g' \
395737b690SBen Gras    -e 's,\&nbsp;,,g' \
405737b690SBen Gras    -e 's,<code>,,g' \
415737b690SBen Gras    -e 's,</code>,,g' \
425737b690SBen Gras    -e 's,<br>, ,g' \
435737b690SBen Gras    -e 's,</td><td>,	,g' \
445737b690SBen Gras    -e 's,�,Aa,g' \
455737b690SBen Gras    -e 's,�,o,g' \
465737b690SBen Gras    -e 's,</td></tr>,,g' |
475737b690SBen Grasawk -F'\t' '{ printf("%s\t%s\t%s\t%s\t%s\n", $2, $3, $4, $6, $1); }' |
485737b690SBen Grasgrep -v href= |
495737b690SBen Grassort > $O1
505737b690SBen Gras
51*84d9c625SLionel Sambucgrep ';[A-Z][A-Z]' $I2 |
525737b690SBen Grastr -d '\015' |
535737b690SBen Grasawk -F ';' '{ print $2 }' |
545737b690SBen Grassort > $O2
555737b690SBen Gras
565737b690SBen Grashdr
575737b690SBen Grasjoin -t '	' -o 1.5,1.1,1.2,1.3,1.4 -1 1 -2 1 $O1 $O2 | sort
58