#!/bin/sh

ALLCOUNTRIES='austria bulgaria canada czech denmark england finland france germanye germanyw hungary italy japan lithuania netherland norway russia spain sweden sweitzerland usa'
HIGHE0='austria canada denmark england finland france germanyw italy japan netherland norway spain sweden sweitzerland usa'
LOWE0='bulgaria czech germanye hungary lithuania russia' 

echo "1952-1996 mortality for: $HIGHE0." > mxall.txt
echo "1952-1996 population for $HIGHE0." > pxall.txt
for DIR in $HIGHE0; do
	# Test for m5296.txt; if so cat results of it and P*, otherwise continue
	if [ -d $DIR ]; then
		pushd $DIR 1>/dev/null
		if [[ ! -e m5296.txt ]]; then
			echo "$DIR:  No m5296.txt.  Listing: $(ls)."
			popd 1>/dev/null
			continue
		else
			echo '' >> '../mxall.txt'
			cat m5296.txt >> '../mxall.txt'
		fi

		echo '' >> '../pxall.txt'
		cat p5296.txt >> '../pxall.txt'
		popd 1>/dev/null
	else
		echo "$DIR: not directory"
	fi
	
done

