If you have an arbitrary number of files you want to generate the union from, use BEDOPS
$ bedops -u A.bed B.bed ... N.bed > answer.bed
If you have an arbitrary number of files whose intervals you want to merge, instead use BEDOPS
$ bedops -m A.bed B.bed ... N.bed > answer.bed
Merging creates new intervals from overlaps between input intervals. Unioning creates a larger set from all the input intervals, but doesn't otherwise modify them. You would pick one of the other operation depending on what you're trying to do.