How to filter a SAM file by a bed file?
Thanks to the helpful comments I figured it out:

samtools view -b -h -L bedfile.bed originalbam.bam &gt; newbam.bam


-b = Output as bed file
-h = include header
-L = only output alignments overlapping the input bed file