If you want singletons then
samtools view -F 4 -f 8 foo.bam will print them out. The flags indicate that the current read is mapped but its mate isn't. To identify which of the reads this is, look at the
0x80 bits. If you wanted, you could combine those with the aforementioned command to get only singletons from read #1 or #2.