samtools(1) view -bo my_sample.bam my_sample.sam
Utilities for the Sequence Alignment/Map (SAM) format
-b      Output in the BAM format.
-o FILE Output file [stdout]
source manpages: samtools