zcat fileA.gz fileB.gz | sort --merge --uniq --compress-prog= gzip | gzip > output.gz