set -u
umask 0077

dst_dir="$1"; shift

sed -n 's/^\([^#:]*\):.*$/\1/p' /etc/nsswitch.conf \
|while read table; do
    dst_file="$dst_dir/$table"
    if [ -f "$dst_file" ]; then
	echo "$0: destination file already exists: $dst_file" 1>&2
	continue
    fi
    getent "$table" >"$dst_file"
done

