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